Skip to content

dependencies distributor controller performance optimization #5971

@CharlesQQ

Description

@CharlesQQ

What would you like to be added:
The following code:

bindingList := &workv1alpha2.ResourceBindingList{}
err := d.Client.List(context.TODO(), bindingList, &client.ListOptions{
Namespace: resourceTemplateKey.Namespace,
LabelSelector: labels.Everything()})
if err != nil {
return err
}
for i := range bindingList.Items {
binding := &bindingList.Items[i]
if !binding.DeletionTimestamp.IsZero() {
continue
}
matched := matchesWithBindingDependencies(resourceTemplateKey, binding)
if !matched {
klog.V(4).Infof("No need to sync binding(%s/%s)", binding.Namespace, binding.Name)
continue
}
klog.V(4).Infof("ResourceBinding(%s/%s) is matched for resource(%s/%s)", binding.Namespace, binding.Name, resourceTemplateKey.Namespace, resourceTemplateKey.Name)
d.genericEvent <- event.TypedGenericEvent[*workv1alpha2.ResourceBinding]{Object: binding}
}
return nil

For example, in our production environment, there are 3372 dependent resources and 13572 resourcebinding resources; each dependent resource will be for looped 13572 times to match the resourcebinding object;
According to the log, a matchesWithBindingDependencies action takes approximately 0.000612s; calculated according to --concurrent-dependent-resource-syncs=30, it will take time to complete all executions
0.000612 * 3372 * 13572 /30 /60 =15 minutes

Why is this needed:

As part of performance optimization

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions