kubernetes-sigs / karpenter

Karpenter is a Kubernetes Node Autoscaler built for flexibility, performance, and simplicity.
Apache License 2.0
641 stars 207 forks source link

perf: Don't reparse selector on each toplogy select check #1822

Closed jonathan-innis closed 1 week ago

jonathan-innis commented 1 week ago

Fixes #N/A

Description

Don't reparse the selector on the TopologyGroup each time we validate whether a pod matches a selector. The call to metav1.LabelSelectorAsSelector causes a regex parse of the selector which is expensive to compute during the scheduling loop

Flame Graph

Screenshot 2024-11-17 at 1 17 53 PM

How was this change tested?

make presubmit

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

k8s-ci-robot commented 1 week ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonathan-innis, njtran

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/karpenter/blob/main/OWNERS)~~ [jonathan-innis,njtran] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment