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

Improve performance of NodeResourcesFit scoring #114121

Closed
alculquicondor opened this issue Nov 24, 2022 · 14 comments · Fixed by #114390
Closed

Improve performance of NodeResourcesFit scoring #114121

alculquicondor opened this issue Nov 24, 2022 · 14 comments · Fixed by #114390
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling.

Comments

@alculquicondor
Copy link
Member

What would you like to be added?

Profiling reveals that a non-negligible amount of time is wasted creating and querying small maps (example: make(resourceToValueMap), with an expected size of 2 or 3). I believe we should be able to replace them with slices for a performance boost.

We should build unit-level benchmarks to proof that the improvements are good, similar to

func BenchmarkTestPodTopologySpreadScore(b *testing.B) {

Why is this needed?

While the plugin has decent performance, if we try to push the limits of kube-scheduler, there's still room for improvement.

@alculquicondor alculquicondor added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 24, 2022
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Nov 24, 2022
@k8s-ci-robot
Copy link
Contributor

@alculquicondor: This issue is currently awaiting triage.

If a SIG or subproject 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.

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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Nov 24, 2022
@alculquicondor
Copy link
Member Author

/sig scheduling

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 24, 2022
@aojea
Copy link
Member

aojea commented Nov 24, 2022

I believe we should be able to replace them with slices for a performance boost.

have you considered sync.Pool? https://pkg.go.dev/sync#example-Pool

@alculquicondor
Copy link
Member Author

That sounds like more overhead than a simple slice. These are all sync operations.

@ruquanzhao
Copy link
Member

Hi, @alculquicondor
Could I take a shot on this?

If I understand correctly,
we need a func BenchmarkTestFitScore() in fit_test.go, then compare slices and small maps.

@alculquicondor
Copy link
Member Author

yes, that's roughly the plan. There will be a lot of trial-and-error.

@tangwz
Copy link
Contributor

tangwz commented Nov 28, 2022

/assign

@ruquanzhao
Copy link
Member

/assign

@tangwz
Copy link
Contributor

tangwz commented Nov 29, 2022

/assign

@ruquanzhao I've already started. Do you want to continue?

@alculquicondor
Copy link
Member Author

/unassign @Zhaoruquan

This was already assigned.

@alculquicondor
Copy link
Member Author

/unassign @ruquanzhao

@tangwz
Copy link
Contributor

tangwz commented Dec 4, 2022

@alculquicondor

If I understand correctly, I need to add a test function like mostResourceScorer and use resourceToValueSlice instead of resourceToValueMap, then add a func BenchmarkTestFitScore() in fit_test.go and run it.

func mostResourceScorer(resToWeightMap resourceToWeightMap) func(requested, allocable resourceToValueMap) int64 {

@alculquicondor
Copy link
Member Author

I suggest you first add the benchmark. Then, try to replace the maps with slices. Probably both resourceToValueMap and resourceToWeightMap. You can use the profiler on the benchmark to see the effects of your changes.

@tangwz
Copy link
Contributor

tangwz commented Dec 5, 2022

I suggest you first add the benchmark. Then, try to replace the maps with slices. Probably both resourceToValueMap and resourceToWeightMap. You can use the profiler on the benchmark to see the effects of your changes.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants