Skip to content

docs(audits): apply_chunk_parallel call sites and per-chunk dispatch benefit (RJN-1) - #4656

Merged
oferchen merged 1 commit into
masterfrom
docs/audits/rjn-1-apply-chunk-parallel-sites
May 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
docs/audits/rjn-1-apply-chunk-parallel-sites

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Audits every workspace caller of ParallelDeltaApplier::apply_chunk_parallel (crates/engine/src/concurrent_delta/parallel_apply.rs:468) and apply_batch_parallel (:499) and tabulates each site's shape, throughput estimate, and parallelism benefit.
  • Headline finding: there are zero non-test, non-bench production call sites today. The receiver's SequentialDeltaPipeline / ParallelDeltaPipeline flow speaks DeltaWork through DeltaConsumer and never touches ParallelDeltaApplier. BR-3i.d's ChunkBuilder has no production callers either. Every existing call to the per-chunk path is a test exercising the typed-error surface, a DashMap shard-contention probe, or a drop-ordering race.
  • The misleading rayon::join(verify, || ()) second-closure no-op flagged in project_rayon_join_per_chunk_noop.md is therefore a naming issue today, not a performance issue.

Recommendation for RJN-2

Rename, do not refactor. Suggested target: apply_one_chunk (parallel with apply_batch). Justifications:

  1. No production hot path exists, so a fan-out refactor cannot deliver throughput today.
  2. Stress and drop-ordering tests deliberately need a single-chunk entry point.
  3. Receiver-side batching belongs with the eventual receiver-wiring work (RJN-3), so the accumulator can also drive the existing DeltaConsumer reorder buffer.

Bench cross-reference

Both bench harnesses (crates/engine/benches/parallel_receive_delta_perf.rs:263 and the BR-3i.f harness crates/engine/benches/parallel_verify_chunk.rs:206 on branch perf/engine-parallel-verify-chunk-bench-br3if, commit 9a4b97f53) drive apply_batch_parallel exclusively. If the receiver ever ships against the per-chunk path, the bench results will over-state achievable scaling. Extending the harness to add a per-chunk cell is deferred to RJN-4.

Test plan

  • Read-only research; no production code, test, or build files modified.
  • git status clean after commit.
  • Single doc file added: docs/audits/rjn-1-apply-chunk-parallel-call-sites-2026-05-21.md.

…benefit (RJN-1)

Catalogues every workspace caller of `apply_chunk_parallel` and
`apply_batch_parallel`, confirms there are zero non-test, non-bench
production call sites today, and traces why the per-chunk path's
no-op `rayon::join` second closure does not currently impact real
traffic. Concludes with a recommendation for RJN-2: rename to
`apply_one_chunk` (or similar) and defer fan-out refactoring to the
receiver-wiring work in RJN-3.

Also notes that the BR-3i.f cores-vs-throughput bench harness uses
`apply_batch_parallel` exclusively, so it will over-state the per-chunk
path's scaling if the receiver pipeline ships against the per-chunk
entry point. Extending the harness with a per-chunk cell is deferred
to RJN-4.

Read-only research; no code changes.
@oferchen
oferchen force-pushed the docs/audits/rjn-1-apply-chunk-parallel-sites branch from 27e3ab7 to 9bcee5a Compare May 21, 2026 08:28
@oferchen
oferchen merged commit 1de0565 into master May 21, 2026
9 checks passed
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 21, 2026
oferchen added a commit that referenced this pull request May 21, 2026
…-2) (#4660)

Per RJN-1 audit (PR #4656): the name `apply_chunk_parallel` was
misleading. The function uses `rayon::join(verify, || ())` with a
no-op second closure - it schedules a single chunk's verify on a
rayon worker but does NOT parallelize across chunks. The actual
multi-chunk parallelism lives in `apply_batch_parallel` via
`chunks.into_par_iter()`.

Rename to `apply_one_chunk` to reflect actual semantics. Update all
17 call sites (per RJN-1: 1 definition + 12 unit tests in
parallel_apply.rs + 2 stress tests in parallel_apply_concurrent.rs
+ 1 drop-ordering test in arc_drain_panic_recovery.rs + 1 test in
chunk_builder.rs). Add rustdoc paragraph clarifying that it is a
single-chunk scheduling primitive, not cross-chunk parallelism, and
direct callers wanting multi-chunk parallel verify to
`apply_batch_parallel(Vec<DeltaChunk>)`.

RJN-3 (batched fan-out at the receiver) deferred until receiver
wiring exists - currently zero production callers per audit.

No semantic code changes. Pure rename + rustdoc edit.
@oferchen
oferchen deleted the docs/audits/rjn-1-apply-chunk-parallel-sites branch May 21, 2026 14:09
oferchen added a commit that referenced this pull request May 21, 2026
…-2 rename (#4676)

RJN-2 (PR #4660, merged) chose the rename path over the fanout-refactor path,
discharging the RJN-1 audit (PR #4656, merged) with apply_chunk_parallel ->
apply_one_chunk plus a rustdoc redirect to apply_batch_parallel. RJN-3
(implement fanout) and RJN-4 (bench scheduler shape) were the "if RJN-2 chose
refactor" branch that did not get taken; this doc closes both.

- RJN-3 stays closed: zero production callers of apply_one_chunk; the real
  multi-chunk win sits in apply_batch_parallel, where ABW-1 (PR #4670) already
  recommended deferring per its quantified 1.03x-1.50x speedup range; the
  ABW-2/3/4 closure doc defers that track pending BR-3j.f (#2508) bench data.
- RJN-4 is N/A: with RJN-3 deferred there is no "after" cell to measure; the
  production-weighted scheduler-shape bench effort belongs in
  parallel_receive_delta_perf via BR-3j.f, not at the per-chunk entry point.
- Re-open conditions: a production caller of apply_one_chunk ships AND
  profiling shows the per-chunk path is hot.

Project memory references project_rayon_join_per_chunk_noop.md and
project_apply_batch_write_serial.md - both observations remain accurate
under the renamed function.
oferchen added a commit that referenced this pull request Aug 24, 2026
…benefit (RJN-1) (#4656)

Catalogues every workspace caller of `apply_chunk_parallel` and
`apply_batch_parallel`, confirms there are zero non-test, non-bench
production call sites today, and traces why the per-chunk path's
no-op `rayon::join` second closure does not currently impact real
traffic. Concludes with a recommendation for RJN-2: rename to
`apply_one_chunk` (or similar) and defer fan-out refactoring to the
receiver-wiring work in RJN-3.

Also notes that the BR-3i.f cores-vs-throughput bench harness uses
`apply_batch_parallel` exclusively, so it will over-state the per-chunk
path's scaling if the receiver pipeline ships against the per-chunk
entry point. Extending the harness with a per-chunk cell is deferred
to RJN-4.

Read-only research; no code changes.
oferchen added a commit that referenced this pull request Aug 24, 2026
…-2) (#4660)

Per RJN-1 audit (PR #4656): the name `apply_chunk_parallel` was
misleading. The function uses `rayon::join(verify, || ())` with a
no-op second closure - it schedules a single chunk's verify on a
rayon worker but does NOT parallelize across chunks. The actual
multi-chunk parallelism lives in `apply_batch_parallel` via
`chunks.into_par_iter()`.

Rename to `apply_one_chunk` to reflect actual semantics. Update all
17 call sites (per RJN-1: 1 definition + 12 unit tests in
parallel_apply.rs + 2 stress tests in parallel_apply_concurrent.rs
+ 1 drop-ordering test in arc_drain_panic_recovery.rs + 1 test in
chunk_builder.rs). Add rustdoc paragraph clarifying that it is a
single-chunk scheduling primitive, not cross-chunk parallelism, and
direct callers wanting multi-chunk parallel verify to
`apply_batch_parallel(Vec<DeltaChunk>)`.

RJN-3 (batched fan-out at the receiver) deferred until receiver
wiring exists - currently zero production callers per audit.

No semantic code changes. Pure rename + rustdoc edit.
oferchen added a commit that referenced this pull request Aug 24, 2026
…-2 rename (#4676)

RJN-2 (PR #4660, merged) chose the rename path over the fanout-refactor path,
discharging the RJN-1 audit (PR #4656, merged) with apply_chunk_parallel ->
apply_one_chunk plus a rustdoc redirect to apply_batch_parallel. RJN-3
(implement fanout) and RJN-4 (bench scheduler shape) were the "if RJN-2 chose
refactor" branch that did not get taken; this doc closes both.

- RJN-3 stays closed: zero production callers of apply_one_chunk; the real
  multi-chunk win sits in apply_batch_parallel, where ABW-1 (PR #4670) already
  recommended deferring per its quantified 1.03x-1.50x speedup range; the
  ABW-2/3/4 closure doc defers that track pending BR-3j.f (#2508) bench data.
- RJN-4 is N/A: with RJN-3 deferred there is no "after" cell to measure; the
  production-weighted scheduler-shape bench effort belongs in
  parallel_receive_delta_perf via BR-3j.f, not at the per-chunk entry point.
- Re-open conditions: a production caller of apply_one_chunk ships AND
  profiling shows the per-chunk path is hot.

Project memory references project_rayon_join_per_chunk_noop.md and
project_apply_batch_write_serial.md - both observations remain accurate
under the renamed function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant