Skip to content

Measure and optimize DeepCopy operations during controller-runtime CreateOrPatch operations #408

@unmarshall

Description

@unmarshall

What you would like to be added?

When controllerutil.CreateOrPatch is invoked it calls the following:

	objPatch := client.MergeFrom(obj.DeepCopyObject().(client.Object))
	statusPatch := client.MergeFrom(obj.DeepCopyObject().(client.Object))

It then converts the objects to unstructure.Unstructured and does a nested field copy

	before, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj.DeepCopyObject())
	if err != nil {
		return OperationResultNone, err
	}

	// Attempt to extract the status from the resource for easier comparison later
	beforeStatus, hasBeforeStatus, err := unstructured.NestedFieldCopy(before, "status")
	if err != nil {
		return OperationResultNone, err
	}

Other expensive calls are reflect.DeepEqual(before, after) as well. Need to investigate on how to optimize this since there can be large number of invocations of this method.

Why is this needed?

Grove at scale need to handle large number of PodCliqueSet, each of which can contain multiple PodClique's. Optimizing costly operations will help ensure that the CPU consumption is kept well within limits.

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions