farmemtopologymanager: extract findNUMACombo() out of Admit() - #4
Open
VijayP30 wants to merge 2 commits into
Open
farmemtopologymanager: extract findNUMACombo() out of Admit()#4VijayP30 wants to merge 2 commits into
VijayP30 wants to merge 2 commits into
Conversation
added 2 commits
July 21, 2026 18:01
Pure extraction, no behavior change -- the first-fit nNUMA/zNUMA combo search was previously an inline block in Admit() with two var declarations; it is now its own named method with the same declarations as named return values. Makes the combo search independently readable/testable and gives future callers (e.g. a retry-after-capacity-change path) something to call without duplicating ~80 lines inline.
The "dedupe a group of nNUMAs neighbor zNUMAs via a map" pattern was duplicated three times: once in findNUMACombo() (filtered to nNUMAs with free CPUs) and twice in candidateBetterThanCurrent() (unfiltered, once for the candidate group and once for the current one). Pulled into one shared helper, uniqueNeighborZNUMAs(nNUMAsGrp, onlyFreeCPUNNUMAs), with each call site keeping its existing filtering behavior via the second argument -- no behavior change, just removes the duplication.
VijayP30
pushed a commit
that referenced
this pull request
Jul 21, 2026
The "dedupe a group of nNUMAs neighbor zNUMAs via a map" pattern was duplicated three times: once in findNUMACombo() (filtered to nNUMAs with free CPUs) and twice in candidateBetterThanCurrent() (unfiltered, once for the candidate group and once for the current one). Pulled into one shared helper, uniqueNeighborZNUMAs(nNUMAsGrp, onlyFreeCPUNNUMAs), with each call site keeping its existing filtering behavior via the second argument -- no behavior change, just removes the duplication. Mirrors the same extraction proposed to #4 (against the stinglet branch), applied here too so this branch stays in sync with that upstream refactor.
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.
Summary
Two small, independently-verified refactors to
farmemtopologymanager, no behavior change:findNUMACombo()out ofAdmit(). The first-fit nNUMA/zNUMA combo search was an ~80-line inline closure; it's now its own named method with identical logic (confirmed by diffing the moved block against the original — the only textual difference is twovardeclarations becoming named return values, semantically identical in Go).uniqueNeighborZNUMAs()helper. The "dedupe a group of nNUMAs' neighbor zNUMAs via a map" pattern was duplicated three times: once infindNUMACombo()(filtered to nNUMAs with free CPUs) and twice incandidateBetterThanCurrent()(unfiltered, once each for the candidate and current group). Pulled into one shared helper taking a filter flag, with each call site keeping its existing filtering behavior exactly as before.Together these make the combo search independently readable/testable and remove real duplication, without touching any decision logic.
Test plan
go build ./cmd/kubelet/...succeedsfindNUMACombo()extraction is textually identical to the original inline code (aside from twovardeclarations becoming named returns)uniqueNeighborZNUMAs()call site preserves its original filtering behavior (the free-CPU filter only applies where it always did)