Skip to content

perf(engine): add bench harness for parallel verify_chunk cores-vs-throughput (BR-3i.f) - #4653

Merged
oferchen merged 1 commit into
masterfrom
perf/engine-parallel-verify-chunk-bench-br3if
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
perf/engine-parallel-verify-chunk-bench-br3if

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Adds a criterion bench harness in crates/engine/benches/parallel_verify_chunk.rs that measures the cores-vs-throughput curve for ParallelDeltaApplier::verify_chunk introduced by BR-3i.c. Sweeps three axes per cell: workload shape, worker count, and negotiated checksum strategy.

  • Workloads
    • A: large/few - 4 files x 256 chunks x 1 MiB (1024 chunks, 1 GiB)
    • B: small/many - 256 files x 64 chunks x 16 KiB (16384 chunks, 256 MiB)
  • Threads: 1, 2, 4, 8, and available_parallelism()
  • Strategies: MD4, MD5, XXH3 (the BR-3i.b supported set)
  • Pool pinning: each cell builds a private rayon::ThreadPool and runs the applier under pool.install so the dispatch surface is genuinely thread-bound, not just nominally limited.
  • Reproducibility: payloads are RNG-filled from SmallRng::seed_from_u64, keyed by (workload, file, chunk). expected_strong digests are pre-computed outside the timed loop so each iteration exercises the real strategy.compute(&chunk.data) + compare path.

Prerequisite

Baseline numbers (Apple Silicon dev box, --sample-size 10 --measurement-time 1)

Throughput in bytes/sec, median of 10 samples.

Workload A - large_chunks_few_files (4 files x 256 chunks x 1 MiB)

threads MD4 MD5 XXH3
1 941 MiB/s 584 MiB/s 15.7 GiB/s
2 1.75 GiB/s 1.07 GiB/s 21.6 GiB/s
4 3.25 GiB/s 2.12 GiB/s 27.2 GiB/s
8 5.17 GiB/s 3.59 GiB/s 25.0 GiB/s
10 5.43 GiB/s 3.67 GiB/s 27.0 GiB/s

Workload B - small_chunks_many_files (256 files x 64 chunks x 16 KiB)

threads MD4 MD5 XXH3
1 912 MiB/s 568 MiB/s 11.3 GiB/s
2 1.56 GiB/s 1022 MiB/s 14.0 GiB/s
4 3.03 GiB/s 2.02 GiB/s 16.6 GiB/s
8 4.81 GiB/s 3.29 GiB/s 16.9 GiB/s
10 4.87 GiB/s 3.42 GiB/s 17.1 GiB/s

Observations on the dev box:

  • MD4 and MD5 scale roughly linearly to 4 cores, then sub-linearly.
  • XXH3 saturates earlier (between 4 and 8 cores) because the per-chunk verify cost is already small relative to the per-file mutex and reorder-buffer overhead - exactly the saturation point a future scheduler heuristic will want to know.
  • Small/many is 10-20% below large/few across strategies, reflecting dispatch and per-file mutex overhead.

These numbers are the BR-3i.f reference; absolute values depend on the host. Run the bench on the target box to capture machine-specific data.

Follow-on enabled

This harness is shape-compatible with BR-3j.f (re-bench after the DashMap migration in PR #4634). Both BR-3i.f and BR-3j.f drive the same ParallelDeltaApplier::apply_batch_parallel surface, so the BR-3j.f re-baseline reuses this bench unchanged.

Test plan

  • cargo fmt --all clean
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings clean
  • cargo build -p engine --features parallel-receive-delta --bench parallel_verify_chunk compiles
  • cargo bench -p engine --features parallel-receive-delta --bench parallel_verify_chunk -- --sample-size 10 --measurement-time 1 --warm-up-time 1 produces output for all 30 cells (3 strategies x 5 thread counts x 2 workloads)
  • CI fmt+clippy, nextest matrix

…roughput (BR-3i.f)

BR-3i.c (PR #4640) replaced the length-only verify stub with a real
strategy.compute(&chunk.data) comparison, so the per-chunk verify path
now has measurable CPU cost. Adds a criterion harness in
crates/engine/benches/parallel_verify_chunk.rs that sweeps:

  - Workload A: 4 files x 256 chunks x 1 MiB (large/few)
  - Workload B: 256 files x 64 chunks x 16 KiB (small/many)
  - Threads: 1, 2, 4, 8, and available_parallelism()
  - Strategies: MD4, MD5, XXH3 (the BR-3i.b supported set)

Each cell pins both the applier concurrency limit and the rayon pool
via ThreadPoolBuilder + pool.install so the dispatch surface is
genuinely thread-bound. Payloads come from a seeded SmallRng keyed by
(workload, file, chunk) for byte-identical reproducibility across
runs. Per-chunk expected_strong digests are pre-computed outside the
timed loop so each iteration exercises the full compute + compare path.

Group throughput reports bytes/sec; chunks/sec is derivable from the
per-cell chunk count and the reported wall time. No new runtime deps;
rand is added to engine dev-dependencies (already a workspace dev-dep).
@oferchen
oferchen force-pushed the perf/engine-parallel-verify-chunk-bench-br3if branch from 9a4b97f to 0f8a212 Compare May 21, 2026 08:12
@oferchen
oferchen merged commit 196b1b4 into master May 21, 2026
55 of 56 checks passed
@oferchen
oferchen deleted the perf/engine-parallel-verify-chunk-bench-br3if branch May 21, 2026 09:03
oferchen added a commit that referenced this pull request Aug 24, 2026
…roughput (BR-3i.f) (#4653)

BR-3i.c (PR #4640) replaced the length-only verify stub with a real
strategy.compute(&chunk.data) comparison, so the per-chunk verify path
now has measurable CPU cost. Adds a criterion harness in
crates/engine/benches/parallel_verify_chunk.rs that sweeps:

  - Workload A: 4 files x 256 chunks x 1 MiB (large/few)
  - Workload B: 256 files x 64 chunks x 16 KiB (small/many)
  - Threads: 1, 2, 4, 8, and available_parallelism()
  - Strategies: MD4, MD5, XXH3 (the BR-3i.b supported set)

Each cell pins both the applier concurrency limit and the rayon pool
via ThreadPoolBuilder + pool.install so the dispatch surface is
genuinely thread-bound. Payloads come from a seeded SmallRng keyed by
(workload, file, chunk) for byte-identical reproducibility across
runs. Per-chunk expected_strong digests are pre-computed outside the
timed loop so each iteration exercises the full compute + compare path.

Group throughput reports bytes/sec; chunks/sec is derivable from the
per-cell chunk count and the reported wall time. No new runtime deps;
rand is added to engine dev-dependencies (already a workspace dev-dep).
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