Repository navigation
perf(dao): count node pods once per refresh - #4370
Merged
Merged
Conversation
Node.List walked all the pods once per node on every refresh, which is O(nodes*pods), and Node.Get converted every pod to a typed v1.Pod only to take the length of the matching ones. Walk the pods once, into a map of counts per node, for both. CountPods and GetPods have no other callers, so they go away.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4367
Node.ListcalledCountPodsfor each node, and each call walked every pod, so a refresh cost nodes × pods.Node.Getconverted every pod to a typedv1.Podonly to count the ones on that node.Both now walk the pods once into a map of counts per node.
CountPodsandGetPodshad no other callers, so they're removed.The benchmarks are in
node_test.go(30 pods per node, GOMAXPROCS=2, i7-9700, Windows 11, median of 3 runs of-benchtime=5x):List, 50 nodesList, 200 nodesList, 1,000 nodesGet, 200 nodesTestNodeListPodCountandTestNodeGetPodCountcheck the counts. golangci-lint v2.13 finds nothing.