[Autoloop: tsb-perf-evolve]#255
Merged
Merged
Conversation
Switch the radix sort ping-pong buffers from SoA (_rxA_idx, _rxA_lo, _rxA_hi, _rxB_idx, _rxB_lo, _rxB_hi — 6 separate typed arrays) to a single AoS layout (_rxA, _rxB — each element occupies 3 consecutive uint32 words: [origRowIdx, loKey, hiKey]). With AoS, all three scatter writes per element target the same cache line (12 consecutive bytes), reducing random-write cache-line pressure ~3× versus the previous SoA layout where each write touched a separate cache line in a separate 1MB buffer. Run: https://github.com/githubnext/tsessebe/actions/runs/25183052353 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This PR is maintained by Autoloop. Each accepted iteration adds a commit to this branch.
Program Goal
Minimize
fitness = tsb_mean_ms / pandas_mean_msforSeries.sortValuesat n=100k. Lower is better;< 1.0means tsb beats pandas.Current best metric: 21.841 (tsb≈116ms / pandas≈5.34ms, iteration 28 — merged via #249)
Iteration 29: AoS scatter layout
Switch the LSD radix sort ping-pong buffers from SoA (6 separate typed arrays:
_rxA_idx,_rxA_lo,_rxA_hi,_rxB_idx,_rxB_lo,_rxB_hi) to a single AoS layout (_rxA,_rxB— each element uses 3 consecutiveuint32words:[origRowIdx, loKey, hiKey]).With SoA, each scatter step writes 3 words to 3 separate large arrays (random positions), touching 3 separate cache lines per element. With AoS, all 3 writes target consecutive addresses in a single array, hitting one cache line per element — ~3× fewer cache-line evictions during scatter.
Hypothesis: The 8×n random scatter writes are the dominant bottleneck at n=100k. Packing all three fields into one cache line per element should reduce cache pressure and improve throughput.
Invariants preserved: same algorithm (8-pass LSD radix), same public signature, same NaN/null handling, same sort correctness. Tests unchanged.
Related issue: #189
Run: https://github.com/githubnext/tsessebe/actions/runs/25183052353