Repository navigation
feat(ipc): application-layer back-pressure groundwork (Phase 1+2 partial) - #670
Merged
Merged
Conversation
…partial) Phase 1 — pipe pool sizing (transport.rs): - The Windows named-pipe pool size cap was hard-coded `.min(16)`, which made the OS-level accept queue the dominant bottleneck under a 670-TU ninja burst. Clients hit `ERROR_PIPE_BUSY` before the daemon ever saw the request, which aliased "daemon overloaded" with "daemon dead" at the client (drove the Layer A/B/C wedge-recovery path from #669 on every natural overload, not just true wedges). - Pool now defaults to `clamp(cpu_count * 4, 16..=128)` with env override via `ZCCACHE_PIPE_POOL_SIZE`. On a 16-core box that's 64 vs the previous 16. Moves the bottleneck inside the daemon where overload can be expressed as a Response::Backpressure reply (Phase 2). Phase 2 — protocol surface (protocol/messages/mod.rs): - New `Response::Backpressure { queue_depth, retry_after_ms, reason }` variant, appended at end of the enum to preserve bincode variant indices for older clients (existing convention used by FingerprintCheckResult, RustArtifactList, GenericToolExecResult). - Daemon-side emission (queue depth threshold check + jittered retry hint) and client-side retry loop with budget + fallback to ephemeral remain TODO — blocked on local disk space for cargo check during this session. Design intent (full doc to land in a follow-up): ACCEPT layer (this commit) — pool sized for expected burst, never reject at the OS layer DISPATCH layer (next commit) — daemon reads request, evaluates real pressure metric, emits Backpressure on overload CLIENT layer (next commit) — honors retry_after_ms with jittered backoff and a budget; falls through to ephemeral on budget exhaustion Refs the daemon-wedge work in #669 (which catches true wedges via Layer A's 90 s recv timeout + force-kill); this series catches the *high load* case in-band so #669's recovery does not fire on natural overload.
This was referenced Jun 5, 2026
zackees
marked this pull request as ready for review
June 7, 2026 21:01
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.
Draft — opening for design feedback, not ready to merge. Phases 3-4 (daemon emission, client retry loop) are TODO; this PR holds Phase 1 (pool sizing) + Phase 2 protocol surface only.
Problem
Under a parallel-build burst of ~670 TUs, the Windows named-pipe pool capped at
.min(16)becomes the dominant bottleneck. Clients hit OS-levelERROR_PIPE_BUSYbefore the daemon ever sees the request, so "daemon overloaded" gets aliased with "daemon dead" at the client — every natural overload looks like a wedge and triggers the Layer A 90 s recv-timeout + force-kill recovery path from #669.#669's recovery is the right safety net for actual wedges. This series prevents it from firing on healthy-but-overloaded daemons by moving the bottleneck inside the daemon where it can be expressed in-band.
Design
Properties this gives that the current design doesn't:
This PR (Phase 1 + Phase 2 partial)
Phase 1 (transport.rs):
.min(16)->clamp(cpu*4, 16..=128)withZCCACHE_PIPE_POOL_SIZEenv override. cargo check clean.Phase 2 (protocol/messages/mod.rs): New
Response::Backpressure { queue_depth, retry_after_ms, reason }appended at end of the enum, following the existing convention (FingerprintCheckResult,RustArtifactList,GenericToolExecResult) so bincode variant indices stay stable for older clients.TODO (separate commits)
retry_after_ms = ((depth - threshold) * 50).min(5000) + jitter(50), emits Backpressure whendepth > ZCCACHE_QUEUE_PRESSURE_THRESHOLD(default 256).cli/commands/wrap/ipc.rs) handles Backpressure: sleeps retry_after_ms, retries up toZCCACHE_BACKPRESSURE_MAX_RETRIES(default 8), falls through to existing ephemeral path on budget exhaustion.Co-existence with #669
Backpressure and wedge-recovery don't collide: Backpressure is an in-band response (instant), wedge requires 90 s of silence. A healthy-but-overloaded daemon sends Backpressure within the wedge window so Layer A never fires; a truly hung daemon sends nothing so Layer A fires as designed.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]