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

perf: Cache the pod request calculation in memory #1825

Conversation

jonathan-innis
Copy link
Member

@jonathan-innis jonathan-innis commented Nov 17, 2024

Fixes #N/A

Description

Cache pod request calculations in memory during scheduling -- this prevents us from calling requests.RequestsForPods a ton of times during the scheduling simulation which causes us to reconstruct the requests. We can calculate this once at the beginning of the scheduling simulation and then just reached for the pre-computed cached value anytime we are trying to use a pod's requests

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 k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 17, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 requested a review from jmdeal November 17, 2024 21:25
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 17, 2024
@coveralls
Copy link

coveralls commented Nov 17, 2024

Pull Request Test Coverage Report for Build 11883702745

Details

  • 19 of 19 (100.0%) changed or added relevant lines in 4 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 81.024%

Files with Coverage Reduction New Missed Lines %
pkg/controllers/disruption/consolidation.go 4 88.55%
Totals Coverage Status
Change from base Build 11882312260: -0.03%
Covered Lines: 8625
Relevant Lines: 10645

💛 - Coveralls

@jonathan-innis jonathan-innis force-pushed the cache-pod-request-calculation branch 2 times, most recently from 4f33b85 to 041e1f9 Compare November 18, 2024 00:22
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 18, 2024
@jonathan-innis jonathan-innis force-pushed the cache-pod-request-calculation branch 9 times, most recently from 4f36e52 to 36f98ee Compare November 18, 2024 04:46
Copy link
Contributor

@engedaam engedaam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2024
@jmdeal
Copy link
Member

jmdeal commented Nov 18, 2024

/hold
There's one more occurrence in NodeClaim which isn't using the cached value on line 110.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 18, 2024
@jonathan-innis jonathan-innis force-pushed the cache-pod-request-calculation branch from 36f98ee to 5500a8d Compare November 18, 2024 04:54
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2024
@jmdeal
Copy link
Member

jmdeal commented Nov 18, 2024

/lgtm
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 18, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 18, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6a036cb into kubernetes-sigs:main Nov 18, 2024
12 checks passed
jmdeal pushed a commit to jmdeal/karpenter that referenced this pull request Nov 18, 2024
jmdeal pushed a commit to jmdeal/karpenter that referenced this pull request Nov 18, 2024
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants