Skip to content

docs(design): tokio::spawn_blocking bridge for rayon CPU work in async daemon (#1751) - #3893

Merged
oferchen merged 1 commit into
masterfrom
design/tokio-spawn-blocking-rayon
May 7, 2026
Merged

oferchen merged 1 commit into
masterfrom
design/tokio-spawn-blocking-rayon

Conversation

@oferchen

@oferchen oferchen commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Designs how the async daemon (Accept quoted fallback override values #1934/Normalize quoted fallback keywords #1935) bridges to rayon-dispatched CPU work (checksums, delta apply, parallel stat) without stalling tokio workers.
  • Recommends a rayon_bridge helper in crates/transfer/src/async_compat.rs that wraps tokio::task::spawn_blocking with a threshold short-circuit, mapping JoinError to upstream-compatible exit codes.
  • Compares the dedicated rayon ThreadPool + block_in_place alternative for worker-pool-aware avoidance of double-spawn cost, and enumerates risks (panic propagation, cancellation, oversubscription, blocking-pool exhaustion).

Tracks #1751.

Test plan

  • Design review: confirm the wrapper API and threshold-gating story align with the async daemon plan in Accept quoted fallback override values #1934/Normalize quoted fallback keywords #1935.
  • Verify the recommended wrapper signature compiles when crates/transfer/src/async_compat.rs is added in the implementation PR.
  • Cross-check call sites listed (crates/checksums/src/rolling/parallel.rs, crates/engine/src/delta/, crates/transfer/src/receiver/parallel.rs) still cover all rayon entry points reachable from async contexts.

…c daemon (#1751)

Designs the bridge between the tokio-driven async daemon (#1934/#1935) and
rayon-dispatched CPU work (checksums, delta apply, parallel stat). Recommends
a `rayon_bridge` helper in `crates/transfer/src/async_compat.rs` using
`tokio::task::spawn_blocking` with a threshold short-circuit, and discusses
the dedicated-pool + `block_in_place` alternative plus risks (double-spawn,
panic propagation, cancellation, oversubscription).
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 7, 2026
@oferchen
oferchen merged commit 50309fc into master May 7, 2026
8 checks passed
@oferchen
oferchen deleted the design/tokio-spawn-blocking-rayon branch May 8, 2026 03:52
oferchen added a commit that referenced this pull request May 18, 2026
…c daemon (#1751) (#3893)

Designs the bridge between the tokio-driven async daemon (#1934/#1935) and
rayon-dispatched CPU work (checksums, delta apply, parallel stat). Recommends
a `rayon_bridge` helper in `crates/transfer/src/async_compat.rs` using
`tokio::task::spawn_blocking` with a threshold short-circuit, and discusses
the dedicated-pool + `block_in_place` alternative plus risks (double-spawn,
panic propagation, cancellation, oversubscription).
oferchen added a commit that referenced this pull request Aug 24, 2026
…c daemon (#1751) (#3893)

Designs the bridge between the tokio-driven async daemon (#1934/#1935) and
rayon-dispatched CPU work (checksums, delta apply, parallel stat). Recommends
a `rayon_bridge` helper in `crates/transfer/src/async_compat.rs` using
`tokio::task::spawn_blocking` with a threshold short-circuit, and discusses
the dedicated-pool + `block_in_place` alternative plus risks (double-spawn,
panic propagation, cancellation, oversubscription).
oferchen added a commit that referenced this pull request Aug 24, 2026
EDG-PANIC.1: workspace audit of bare slice indexing patterns on
attacker-controlled buffers (protocol/transfer/checksums/compress).
~314 indexing sites reviewed; only the two known UTS-18 sites in
BufferedMap surfaced as suspect, both with a fix in flight via
PR #5566. All other indexing is bounds-checked on the prior line,
backed by fixed-size [u8; N] arrays, min-clamped, or covered by a
length-prefix or library contract. Findings written to
docs/audits/edg-panic-1-bare-slice-indexing.md with follow-up items
enumerated as future EDG-PANIC tasks.

EDG-PANIC.3: pin the BufferedMap basis-slice bounds contract with
five negative-bounds unit tests against map_ptr (the BufferedMap
"slice" accessor):

  - offset past EOF returns Err
  - length overflow (usize::MAX) returns Err
  - u64::MAX offset returns Err
  - offset == file_size with non-zero len returns Err
    (offset == file_size with zero len is a legitimate empty slice)
  - range straddling EOF returns Err

Each test asserts io::ErrorKind::UnexpectedEof so a future change
that drops or weakens the saturating_add guard is caught at the
test boundary. Mirrors the malformed delta stream attack surface
UTS-18 root-caused (range end index N out of range for slice of
length M aborting the process).

Refs: #3891, #3893
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