Introduce relevance filter for ClusterSnapshot #9596
@x13n: GitHub didn't allow me to request PR reviews from the following users: tetianakh.
Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.
<details>
In response to this:
>This feature results in visible (up to almost 10x) loop time reduction in the provided anti-affinity surge benchmark, depending on the topology used.
>$ go test -v ./core/bench -bench BenchmarkRunOnceAffinitySurge -run ^$ -benchtime=1x
>goos: linux
>goarch: amd64
>pkg: k8s.io/autoscaler/cluster-autoscaler/core/bench cpu: AMD EPYC 7B13
>BenchmarkRunOnceAffinitySurge_Hostname_Default
>BenchmarkRunOnceAffinitySurge_Hostname_Default-64 1 606368983108 ns/op
>BenchmarkRunOnceAffinitySurge_Hostname_RelevantOnly
>BenchmarkRunOnceAffinitySurge_Hostname_RelevantOnly-64 1 72663479496 ns/op
>BenchmarkRunOnceAffinitySurge_Zonal_Default
>BenchmarkRunOnceAffinitySurge_Zonal_Default-64 1 605389016837 ns/op
>BenchmarkRunOnceAffinitySurge_Zonal_RelevantOnly
>BenchmarkRunOnceAffinitySurge_Zonal_RelevantOnly-64 1 313136394981 ns/op
>#### What type of PR is this?
>/kind feature
>#### What this PR does / why we need it:
>Performance improvement.
>#### Which issue(s) this PR fixes:
><!--
>Automatically closes linked issue when PR is merged.
>Usage:
Fixes #<issue number>, or Fixes (paste link of issue).>_If PR is about
failing-tests or flakes, please post the related issues/tests in a comment and do not use Fixes_>-->
>Fixes #
>#### Special notes for your reviewer:
>#### Does this PR introduce a user-facing change?
><!--
>If no, just write "NONE" in the release-note block below.
>If yes, a release note is required:
>Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
>For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
>-->
>``
release-note
>Added a new, experimental --relevance-filter-enabled flag, pruning irrelevant nodes before scale up simulations, significantly improving performance at scale when computationally complex scheduling predicates are used (inter pod affinity, topology spreading).
>>
>#### Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
>
><!--
>This section can be blank if this pull request does not require a release note.
>
>When adding links which point to resources within git repositories, like
>KEPs or supporting documentation, please reference a specific commit and avoid
>linking directly to the master branch. This ensures that links reference a
>specific point in time, rather than a document that may change over time.
>
>See here for guidance on getting permanent links to files: https://help.github.com/en/articles/getting-permanent-links-to-files
>
>Please use the following format for linking documentation:
>- [KEP]: <link>
>- [Usage]: <link>
>- [Other doc]: <link>
>-->
>
docs
>
``
>/cc @tetianakh @towca
>/hold to add unit tests beyond the benchmark
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
This issue is currently awaiting triage.
If SIG Autoscaling contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.
<details>
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/kubernetes/autoscaler/pull/9596#" title="Author self-approved">x13n</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
It looks like the benchmark takes too much time to be useable as a CI job. Especially that it is run 8 times to eliminate noise.
Any chance to decrease the node count? I believe it would still be a worthy signal.
The benefit of doing this is mainly visible at scale. I thought of this benchmark as something that would be triggered manually, not as a part of CI. That being said, smaller scale version for CI does sound useful, let me try and split this into larger scale manual and medium scale CI versions.
Updated, PTAL.
Thanks! This looks promising.
I noticed that the PR bench failed with 143 error though, as it went out of memory. I believe I've found the cause. PTAL #9632
What overhead does this change introduce in case when all nodes are relevant (e.g. a depoyment with host scoped AA for itself, so there's one pod per node)?
For host scoped anti-affinity no existing nodes are actually relevant (for host scoped pod affinity a single node is relevant to ensure it works correctly for the first pod). In the scenario you describe, pretty much the entire snapshot should get filtered out.
Ok, true, that was a bad example. What if all pods have AA that's e.g. zonal, or nodepool scoped?
If there is zonal/nodepool scoped AA, then there will only be a single node with such pod per topology, and only such nodes should stay. There is an edge case where there is a pod A with zonal anti-affinity to all pods with a specific label (but these pods don't have anti-affinity to that label themselves, so it is possible for them to coexist in the same zone). This could be further optimized as a follow up if needed, to only keep one such node per topology.
PR needs rebase.
<details>
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
On the last SIG meeting I mentioned I will be experimenting with embedding Karpenter scheduling engine into CA in preparation of the codebase for SDA. In that world, this concept of a relevance filter is likely unnecessary, so closing this PR.
/close
@x13n: Closed this PR.
<details>
In response to this:
>On the last SIG meeting I mentioned I will be experimenting with embedding Karpenter scheduling engine into CA in preparation of the codebase for SDA. In that world, this concept of a relevance filter is likely unnecessary, so closing this PR.
>/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
</details>
Choraden
x13n
This feature results in visible (up to almost 10x) loop time reduction in the provided anti-affinity surge benchmark, depending on the topology used.
$ go test -v ./core/bench -bench BenchmarkRunOnceAffinitySurge -run ^$ -benchtime=1x
goos: linux
goarch: amd64
pkg: k8s.io/autoscaler/cluster-autoscaler/core/bench cpu: AMD EPYC 7B13
BenchmarkRunOnceAffinitySurge_Hostname_Default
BenchmarkRunOnceAffinitySurge_Hostname_Default-64 1 606368983108 ns/op
BenchmarkRunOnceAffinitySurge_Hostname_RelevantOnly
BenchmarkRunOnceAffinitySurge_Hostname_RelevantOnly-64 1 72663479496 ns/op
BenchmarkRunOnceAffinitySurge_Zonal_Default
BenchmarkRunOnceAffinitySurge_Zonal_Default-64 1 605389016837 ns/op
BenchmarkRunOnceAffinitySurge_Zonal_RelevantOnly
BenchmarkRunOnceAffinitySurge_Zonal_RelevantOnly-64 1 313136394981 ns/op
What type of PR is this?
/kind feature
What this PR does / why we need it:
Performance improvement.
Which issue(s) this PR fixes:
<!--
Automatically closes linked issue when PR is merged.
Usage:
Fixes #<issue number>, orFixes (paste link of issue)._If PR is about
failing-tests or flakes, please post the related issues/tests in a comment and do not useFixes_-->
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
For more information on release notes see: https://git.k8s.io/community/contributors/guide/release-notes.md
-->
``
release-noteAdded a new, experimental --relevance-filter-enabled flag, pruning irrelevant nodes before scale up simulations, significantly improving performance at scale when computationally complex scheduling predicates are used (inter pod affinity, topology spreading).
docs
``
/cc @tetianakh @towca
/hold to add unit tests beyond the benchmark