bench(engine): profile ReorderBuffer cache behavior at 1M items (#1854)#4180
Merged
Conversation
423b9ae to
012a769
Compare
Add a Criterion bench that exercises ReorderBuffer's insert/drain path at 1M out-of-order indexed items across three payload sizes (32 B, 256 B, 4 KB) and three insertion patterns (fully reverse, random shuffle, near-in-order with 10% deltas). The bench is gated behind BENCH_REORDER_CACHE=1 so default cargo bench runs stay fast. The top-of-file documents how to drive perf stat (Linux) and cachegrind (any platform) against the produced binary, and how to interpret the numbers - favorable cache metrics keep the existing Box<[Option<T>]> layout, while unfavorable metrics motivate a flat Vec plus occupancy-bitmap layout or a hot/cold storage split. Payloads are pre-built outside the timed section via iter_batched so the measurement reflects ReorderBuffer ops, not allocation. Capacity is sized per pattern so no insert ever triggers grow().
012a769 to
726a694
Compare
This was referenced May 17, 2026
oferchen
added a commit
that referenced
this pull request
May 18, 2026
… (#4180) * chore(bench): profile ReorderBuffer cache behavior at 1M items (#1854) Add a Criterion bench that exercises ReorderBuffer's insert/drain path at 1M out-of-order indexed items across three payload sizes (32 B, 256 B, 4 KB) and three insertion patterns (fully reverse, random shuffle, near-in-order with 10% deltas). The bench is gated behind BENCH_REORDER_CACHE=1 so default cargo bench runs stay fast. The top-of-file documents how to drive perf stat (Linux) and cachegrind (any platform) against the produced binary, and how to interpret the numbers - favorable cache metrics keep the existing Box<[Option<T>]> layout, while unfavorable metrics motivate a flat Vec plus occupancy-bitmap layout or a hot/cold storage split. Payloads are pre-built outside the timed section via iter_batched so the measurement reflects ReorderBuffer ops, not allocation. Capacity is sized per pattern so no insert ever triggers grow(). * style(engine): fix clippy doc-lazy-continuation and hex literal grouping * style(engine): break paragraph out of nested list in bench doc
oferchen
added a commit
that referenced
this pull request
May 18, 2026
… (#4180) * chore(bench): profile ReorderBuffer cache behavior at 1M items (#1854) Add a Criterion bench that exercises ReorderBuffer's insert/drain path at 1M out-of-order indexed items across three payload sizes (32 B, 256 B, 4 KB) and three insertion patterns (fully reverse, random shuffle, near-in-order with 10% deltas). The bench is gated behind BENCH_REORDER_CACHE=1 so default cargo bench runs stay fast. The top-of-file documents how to drive perf stat (Linux) and cachegrind (any platform) against the produced binary, and how to interpret the numbers - favorable cache metrics keep the existing Box<[Option<T>]> layout, while unfavorable metrics motivate a flat Vec plus occupancy-bitmap layout or a hot/cold storage split. Payloads are pre-built outside the timed section via iter_batched so the measurement reflects ReorderBuffer ops, not allocation. Capacity is sized per pattern so no insert ever triggers grow(). * style(engine): fix clippy doc-lazy-continuation and hex literal grouping * style(engine): break paragraph out of nested list in bench doc
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.
Summary
crates/engine/benches/reorder_buffer_cache.rs, a Criterion bench that exercisesReorderBufferinsert/drain at 1M out-of-order indexed items.Throughput::Elements.perf stat -e cache-misses,cache-references(Linux) andvalgrind --tool=cachegrind(any platform), plus what favorable / unfavorable counter results would imply for the storage layout (keepBox<[Option<T>]>vs. switch to flatVec<T>+ occupancy bitmap, or hot/cold split).Notes
BENCH_REORDER_CACHE=1so defaultcargo benchruns remain fast - per-cell wall time is 5-30 s at 1M items.iter_batched(PerIteration)so the measurement reflectsReorderBufferoperations, not allocator work.grow(); the steady-state ring is what gets profiled.ReorderBufferproduction code.Test plan
BENCH_REORDER_CACHE=1 cargo bench -p engine --bench reorder_buffer_cachecompletes on a Linux host.perf stat -e cache-misses,cache-references,L1-dcache-load-misses,LLC-load-missesnumbers captured for the 1M cells (driven from instructions in the bench file header).payload256/shuffle) annotated viacg_annotate.