Repository navigation
fix(solver): index pending assignments by key in the path overlay - #284
Merged
Merged
Conversation
The zero-regression gate had no case for grouped-scalar assignment groups, so the dense required batch and the grouped local-search neighborhood ran in production without a performance guard. assignment_required solves a rostering-shaped assignment group (504 required shifts, one shift per nurse per day, a late-to-early succession rule) with the default runtime, which commits the dense required batch. The cross-tree order hash is the constructed roster. assignment_neighborhood enumerates the compiled grouped-scalar local-search neighborhood of the same group over that roster, including the augmenting-path repairs.
The required batch keeps one pending row per placed required entity in the path overlay, and every blocker and rule-member query scanned all pending rows. The batch was quadratic in the required rows: on INRC-II n120w8 it took 1.3 s, so a 1-second solve stopped inside it and kept none of its 2844 or 2872 placements. The scan came in with 3992802 (0.20.4). Pending assigned rows are now linked into intrusive chains per capacity key and per (value, sequence) coordinate; queries walk one chain. Rule members are iterated instead of collected. The batch reserves its overlay for the required rows and releases it before final validation, and drops the edited-entity set, which a depth-0 discovery could never hit. Blockers and verdicts are unchanged: a seeded differential test compares them with a full-scan oracle across set, checkpoint, rollback and clear sequences, and the constructed roster is identical on both trees. assignment_required: 30x faster, allocations -0.5%, bytes -1.3%, peak -10%. assignment_neighborhood: wall -1.6%, allocations equal, bytes and peak lower. n120w8 H0/H1 at 1 s: required batch 1334/1416 ms -> 60 ms, both feasible. Closes #283
This was referenced Nov 30, 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.
The required batch of a grouped-scalar assignment construction was quadratic in its required rows. On INRC-II n120w8 it took 1.3 s, so a 1-second solve stopped inside it and kept none of its placements (2844 / 2872 required rows unassigned). Closes #283.
Cause
The first bad commit is 3992802 (0.20.4), bisected commit by commit with the bench NRP adapter built against path dependencies. Its parent d2b3c2d solves both instances at 1 s; 3992802 fails both 3/3. The issue's earlier 0.20.0 boundary came from
cargo update -p solverforge --precise 0.20.0, which leavessolverforge-solveron 0.20.4 because the facade then depended on its sub-crates by caret version.3992802 moved the batch onto
AssignmentPathOverlay, which keeps one pending row per placed required entity.blockersandcollect_membersscanned every pending row on every query, which made the batch quadratic. A profile of 3992802 on H0: 62%collect_members, 26%blockers.Fix
edited_entities: a depth-0 discovery that yields one edit always assigns the still-unassigned root, so the check never fired.Semantics are unchanged. Blockers and the rule verdict are compared with a full-scan oracle across 64 seeded sequences of set, checkpoint, rollback and clear (
indexed_overlay_blockers_match_full_scan_oracle_across_rollbacks).required_batch_key_work_grows_linearly_with_required_rowsfails on main: key hook calls grow from 67,072 at 256 rows to 1,054,720 at 1024 rows.Gate cases
There was no gate case for grouped-scalar assignment, so the first commit adds two, registered in the script and AGENTS.md:
assignment_required: the default runtime's required batch on a 504-shift rosterassignment_neighborhood: the compiled grouped-scalar local-search neighborhood over that roster, including augmenting-path repairs. The path overlay accounts for about 19% of its profile.Shared-source smoke against main, 32 iterations:
Verification
make lint: passed (fmt, clippy all targets, doc-names, file-length, facade, public-api, deps)make test: passed