Repository navigation
fix(solver): keep required construction's buffers across placements - #286
Merged
Merged
Conversation
Placing required rows one move at a time (f4cc2fa) allocated again on every placement: the augmenting search's blocker list and visited set, its edit list, each row's candidate values, a fresh candidate store and target list, the completed-slot set and one probe placement per probed row, and the affected-row list of every grouped move. The gate measured assignment_required at 496,897 allocations against 134,145 on 0.31.4 (+270%) and 52.7 MB against 32.0 MB allocated. The construction cursor now owns those buffers and refills them: - the assignment state pools the search's blocker list and visited set, and the move cursor its edit list; - candidate values are refilled into the cursor's buffers (`candidate_values_into`, `extend_candidate_values`); - the store, targets, touched rows, completed slots and resume scratch travel with the generator through `recycle`; - completion is probed through one reusable placement (`retarget`); - a grouped move iterates its affected rows from its edits instead of storing a list, and checks repeated rows by a scan instead of a set. One iteration of assignment_required now allocates 3,698 times and 478,017 bytes (0.31.4: 4,193 and 1,000,709), peak 240,620 (0.31.4: 360,984), with the same roster; assignment_neighborhood allocates 180,248 times (0.31.4: 206,448) with the same candidates.
This was referenced Dec 1, 2026
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.
Follow-up to #285 (#283). Fixes the allocation regression #285 introduced.
Problem
#285 places required rows one move at a time. Every placement allocated its scratch again:
The gate measured
assignment_requiredagainst 0.31.4 at:Change
The construction cursor owns those buffers and refills them:
candidate_values_into,extend_candidate_values).recycle.Placement::retarget).Verification
One iteration of each case, against 0.31.4 (gate-smoke, shared bench source):
make lint: passes.make test: passed before two clippy-only edits;cargo test -p solverforge-solver --lib(818 tests) passes after them.