Skip to content

perf(solver): simulate the ruin shuffle sparsely and keep the list ruin count inlined - #249

Merged
blackopsrepl merged 2 commits into
mainfrom
perf/ruin-sparse-shuffle
Nov 11, 2026
Merged

blackopsrepl merged 2 commits into
mainfrom
perf/ruin-sparse-shuffle

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

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.

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
@blackopsrepl
blackopsrepl merged commit 0773934 into main Nov 11, 2026
7 checks passed
@blackopsrepl
blackopsrepl deleted the perf/ruin-sparse-shuffle branch November 11, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(solver): ruin batch generation still walks the permutation and perturbs list cursor codegen

1 participant