Repository navigation
perf: add 10K-10M scaling benchmark for ring-buffer ReorderBuffer - #3419
Merged
Merged
Conversation
Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
oferchen
added a commit
that referenced
this pull request
May 1, 2026
) Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
oferchen
added a commit
that referenced
this pull request
May 5, 2026
) Task #1853 verification. The concurrent_delta::ReorderBuffer was already converted to a Box<[Option<T>]> ring buffer in #1734 (with adaptive capacity scaling added in #3392), so the BTreeMap-vs-ring decision is already settled in production code. This change adds the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at the 10M-file scale that motivated the task, and corrects the stale "BTreeMap-backed" doc comment in the concurrent_delta module overview. The benchmark compares the production ring buffer against a self- contained BTreeMap baseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behind BENCH_REORDER_10M=1 so default invocations stay fast; CI can opt in when targeting the scaling regression dataset. No production behaviour changes. Existing reorder_buffer tests already cover gap-larger-than-capacity (force_insert grows the ring) and ring wrap-around.
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
Task #1853 asked for a VecDeque + index-mask ring-buffer prototype to replace the
BTreeMapin theReorderBufferhot path. Investigation found the conversion was already done in #1734 (Box<[Option<T>]>indexed ring buffer with O(1) insert and drain) and further improved in #3392 (adaptive capacity scaling). The productionconcurrent_delta::ReorderBufferis no longer aBTreeMapand has been the ring-buffer variant for a while.This PR therefore takes the alternate branch from the task description: verify the existing implementation handles the gap-larger-than-capacity and wrap-around cases correctly (existing
force_insert_bypasses_capacity,force_insert_beyond_capacity_then_drain, andring_buffer_wraps_correctlytests cover these), and add the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at million-file scale.crates/engine/benches/reorder_buffer_scaling.rscompares the production ring buffer against a self-containedBTreeMapbaseline at 10K, 100K, 1M, and 10M items. The 10M case is gated behindBENCH_REORDER_10M=1so default invocations stay fast; CI can opt in when targeting the scaling regression dataset.BTreeMap-backeddoc comments inconcurrent_delta/mod.rscorrected to describe the ring-buffer-backed implementation.The criterion CI artifact will publish absolute timings; the expectation is roughly linear scaling for the ring path (constant ns/item across counts) versus super-linear scaling for the
BTreeMapbaseline.Test plan
cargo bench -p engine --bench reorder_buffer_scalingruns without errorsBENCH_REORDER_10M=1for the 10M data point