Skip to content

perf: add 10K-10M scaling benchmark for ring-buffer ReorderBuffer - #3419

Merged
oferchen merged 1 commit into
masterfrom
perf/reorder-buffer-ring
Apr 28, 2026
Merged

oferchen merged 1 commit into
masterfrom
perf/reorder-buffer-ring

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Task #1853 asked for a VecDeque + index-mask ring-buffer prototype to replace the BTreeMap in the ReorderBuffer hot 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 production concurrent_delta::ReorderBuffer is no longer a BTreeMap and 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, and ring_buffer_wraps_correctly tests cover these), and add the scaling benchmark called for in #1853 to confirm O(1) per-item behaviour at million-file scale.

  • New benchmark crates/engine/benches/reorder_buffer_scaling.rs 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.
  • Stale BTreeMap-backed doc comments in concurrent_delta/mod.rs corrected to describe the ring-buffer-backed implementation.
  • No production code behaviour changes.

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 BTreeMap baseline.

Test plan

  • cargo bench -p engine --bench reorder_buffer_scaling runs without errors
  • CI bench artifact shows ring buffer ns/item is roughly flat from 10K to 1M
  • Optional: rerun with BENCH_REORDER_10M=1 for the 10M data point
  • Existing reorder buffer tests continue to pass (no production changes)

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
oferchen merged commit 515f066 into master Apr 28, 2026
42 of 43 checks passed
@oferchen
oferchen deleted the perf/reorder-buffer-ring branch April 28, 2026 22:50
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant