Repository navigation
perf(solver): simulate the ruin shuffle sparsely and keep the list ruin count inlined - #249
Merged
Merged
Conversation
Restoring only the touched permutation positions removed the per-batch reset, but the shuffle still read random positions of a 4,096-entry array that the reset used to keep in L1, so simulated data-L1 misses rose 7.4% in the gate's ruin case. The partial Fisher-Yates shuffle now records only the positions a swap displaced in a map sized by the largest ruin count; every other position holds its own index. Batches and random draws are unchanged (the reference test still compares them with the full-reset shuffle), each batch costs O(ruin count) time and memory, and no entity-sized array is built.
Adding a non-generic ruin batch function changed LLVM's inlining in the list kernel: RuinCursor::choose_ruin_count stopped being inlined, which re-laid-out the large RuntimeListSlotCursor dispatch that every list neighborhood runs through (nearby_swap +0.37% instructions, +8.9% branch misses on every layout). The four-line function is now always inlined, as v0.26.0 compiled it; the dispatch matches v0.26.0's machine code apart from padding and instruction counts are equal again. Closes #248
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.
Closes #248. Reference test unchanged and green; smoke gate (15 trials, rotating layouts) on ruin: wall -41.8%, instructions -55.5%, sim D1 -3.2%, allocations equal. nearby_swap's RuntimeListSlotCursor dispatch matches v0.26.0 machine code apart from padding.