Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor estimation #6667

Merged
merged 2 commits into from
Apr 5, 2024
Merged

Conversation

kisieland
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Introduces optimization to the binpacking estimator, which changes the time complexity from O(pods * nodes) to O(pods) in cases of homogeneous pods.

The PR also introduces a benchmark that shows 5x improvement:
The previous version took ~25s:

goos: linux
goarch: amd64
pkg: k8s.io/autoscaler/cluster-autoscaler/estimator
cpu: AMD EPYC 7B12
BenchmarkBinpackingEstimate-48    	       1	25418848308 ns/op	15018690016 B/op	144793817 allocs/op
PASS
ok  	k8s.io/autoscaler/cluster-autoscaler/estimator	25.488s

The new version takes less than 5s:

goos: linux
goarch: amd64
pkg: k8s.io/autoscaler/cluster-autoscaler/estimator
cpu: AMD EPYC 7B12
BenchmarkBinpackingEstimate-48    	       1	4805105872 ns/op	2023739088 B/op	 3574976 allocs/op
PASS
ok  	k8s.io/autoscaler/cluster-autoscaler/estimator	4.869s

Which issue(s) this PR fixes:

Special notes for your reviewer:

Split the PR into two commits:
First one introduces a required pod-equivalence abstraction
Second one uses this new fact in the estimation

For now I kept the logic in one function in the estimation to make clear what changes were made, but I am happy to split it into further functions.

Does this PR introduce a user-facing change?

No

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NA

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. area/cluster-autoscaler labels Mar 28, 2024
@k8s-ci-robot k8s-ci-robot requested review from vadasambar and x13n March 28, 2024 16:51
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 28, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @kisieland. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2024
@kisieland
Copy link
Contributor Author

/assign @x13n

@kisieland kisieland force-pushed the refactor-estimation branch from 50c8e84 to 03d2bc8 Compare March 29, 2024 15:04
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 29, 2024
@kisieland kisieland requested a review from x13n March 29, 2024 15:06
The grouping should be made by the schedulability equivalence
meaning we can introduce optimizations to the binpacking.

Introduce a benchmark that estimates capacity needed for 51k pods,
which can be grouped to two equivalence groups 50k and 1k.
@kisieland kisieland force-pushed the refactor-estimation branch from 03d2bc8 to 0dee120 Compare April 2, 2024 10:18
@kisieland kisieland requested a review from x13n April 2, 2024 10:18
@x13n
Copy link
Member

x13n commented Apr 4, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 4, 2024
The optimization uses the fact that pods which are equivalent do not
need to be check multiple times against already filled nodes.
This changes the time complexity from O(pods*nodes) to O(pods).
@kisieland kisieland force-pushed the refactor-estimation branch from 0dee120 to 5aa6b2c Compare April 4, 2024 17:16
@x13n
Copy link
Member

x13n commented Apr 5, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 5, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kisieland, x13n

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 5, 2024
@k8s-ci-robot k8s-ci-robot merged commit 425b91e into kubernetes:master Apr 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants