Repository navigation
feat(client-pull,node): byte-progress throughput-floor stall detection (#1797) - #1889
Conversation
#1797) Replace whole-frame inactivity stall detection with a byte-level windowed throughput floor across both requester paths. Bytes are counted off the QUIC stream sub-frame via a ProgressReader; a ThroughputFloor aborts a pull when the bytes across a trailing window fall below floor_bps * window (one byte when floor_bps == 0). Frame-size-independent, so a large frame arriving slowly is not mistaken for a stall, and a slow drip below the floor is caught. The abort is requester-local policy and non-attributable: the node path routes a stall like OurDeadline (suppress the (peer, hash) pair, no EWMA), removing the Stalled -> Outcome::Unreachable scoring. PullStalled and PullTimeout stay distinct metrics. Config gains node_pull_stall_window_sec (20) and node_pull_min_throughput_bps (4096); the CLI gains --min-throughput-bps. The read future is pinned and polled across sampler ticks rather than recreated: read_client_message is not cancellation-safe, so dropping it mid-frame would lose read bytes and desynchronise the stream. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…DR 005/008, #1797) ADR 005 §Retry behavior states the byte-progress primitive: a time budget to first byte, then a minimum-throughput floor over a trailing window for steady state, both requester-local and non-attributable, with a credit-window payment pause excluded. §Non-empty chunk rebases its rationale on byte throughput. ADR 008 states that a throughput-floor / inactivity abort produces no outcome and never updates the EWMA. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates requester-side stall detection for paid pulls (both node-to-node cache-miss pulls and CLI fetch) from whole-frame inactivity to a byte-level, windowed throughput-floor model, and adjusts reputation handling so throughput-floor aborts remain non-attributable.
Changes:
- Introduces sub-frame byte counting (
ProgressReader) and a windowed throughput floor (ThroughputFloor) to classify stalls vs timeouts without frame-size coupling. - Renames node pull stall config from an inactivity timeout to a throughput window (
node_pull_stall_window_sec) and adds a minimum throughput floor (node_pull_min_throughput_bps), with CLI support (--min-throughput-bps). - Updates node classification/metrics and ADRs to reflect the new “non-attributable stall” rule (no EWMA update / no
Outcome::Unreachable).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/protocol/src/client.rs | Updates protocol docs around the non-empty ChunkData invariant in light of byte-progress tracking. |
| crates/node/tests/sighup_signal.rs | Updates resolved-config fixtures for renamed stall window + new throughput floor field. |
| crates/node/tests/node_origin_pull.rs | Updates integration tests/fixtures and renames tests to reflect non-attributable mid-stream stalls. |
| crates/node/tests/anvil_bringup_shutdown_e2e.rs | Updates resolved-config fixtures for renamed stall window + new throughput floor field. |
| crates/node/src/selection.rs | Updates outer deadline derivation docs to refer to throughput-floor window. |
| crates/node/src/runtime/reload.rs | Threads new cache config fields through reload/default config and restart-required detection. |
| crates/node/src/runtime/mod.rs | Wires new stall_window + min_throughput_bps into NodeOriginConfig and deadline derivation. |
| crates/node/src/node_origin/mod.rs | Switches node-origin stall logic to throughput-floor semantics and makes stalls non-attributable (suppression only). |
| crates/node/src/metrics.rs | Updates metric docs for stall vs timeout semantics and the non-attribution rule. |
| crates/e2e/src/client.rs | Updates PullDeadlines::new call sites to include floor_bps. |
| crates/common/src/config/types.rs | Renames config knob and documents new throughput floor configuration. |
| crates/common/src/config/resolved.rs | Adds resolved fields for stall window + minimum throughput floor. |
| crates/common/src/config/mod.rs | Adds defaults and resolver validation for stall window + throughput floor; updates docs/tests. |
| crates/common/src/cli/fetch.rs | Extends CLI args with --min-throughput-bps and updates validation/docs for window+floor behavior. |
| crates/client-pull/src/scheduler.rs | Adjusts module docs (minor refactor of intra-doc links). |
| crates/client-pull/src/progress.rs | New: implements ProgressReader and ThroughputFloor with unit tests. |
| crates/client-pull/src/lib.rs | Integrates byte-progress throughput-floor detection into buffered + progressive pull receive loops and updates deadline APIs. |
| crates/cli/tests/config_validate.rs | Updates config summary expectations for new window + throughput floor reporting. |
| crates/cli/src/commands/fetch.rs | Threads CLI throughput floor into PullDeadlines::capped construction. |
| crates/cli/src/commands/config.rs | Updates config summary output and default config template for new stall window + throughput floor. |
| crates/cli/src/commands/bundle_pull.rs | Threads CLI throughput floor into bundle pull’s PullDeadlines::capped construction. |
| adr/008-reputation.md | Documents non-attributable handling for throughput-floor/inactivity aborts. |
| adr/005-protocol.md | Updates retry behavior + non-empty chunk rationale for byte-progress throughput-floor stall detection. |
Suppressed comments (1)
crates/client-pull/src/lib.rs:2639
- Same starvation issue as the buffered path:
biased;makes the read arm always win when both arms are ready, sosampler.tick()may never be consumed and the throughput floor may never be evaluated.
tokio::select! {
biased;
r = &mut read => return r,
_ = sampler.tick() => {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| tokio::select! { | ||
| biased; | ||
| r = &mut read => break r?, | ||
| _ = sampler.tick() => { |
There was a problem hiding this comment.
Not reachable, I think — the two arms are not independent here.
The read arm becomes ready only when a whole frame has come off the wire, and those bytes are already in the counter by then (ProgressReader tallies inside poll_read, sub-frame). So a tick lost to biased is always a tick where byte progress just happened.
Sustained starvation would need every poll of the read arm to complete immediately, i.e. a complete frame already buffered each time we look. On frame completion the loop breaks out, processes the chunk, and re-enters with a fresh read future that is polled first — it returns Pending unless the sender has yet another whole frame queued. Keeping that up means the sender is outrunning this loop; with frames carrying >= 1 byte (#1088) and the per-chunk work being a memcpy plus interval-boundary metering, that rate is orders of magnitude above the 4096 B/s default floor. The sub-floor case Copilot describes (slow drip) is exactly the case where the read arm is Pending and the tick wins.
The reverse hazard is the one that bit: dropping the read future per tick desynchronises framing, since read_frame uses read_exact. That is why the future is pinned.
I have recorded the argument in the comment at both select sites rather than changing the code.
| /// the decoder, not here). Enforces `ChunkData`'s non-empty FLOOR (#1088) — an | ||
| /// oversized frame is refused earlier still, by the framing layer's | ||
| /// `MAX_MESSAGE_SIZE`, before it allocates — plus the `cumulative <= expected_wire_bytes` overrun guard | ||
| /// (ADR 005 §`cdn/client/v1`). The floor is the load-bearing one: it is what lets the | ||
| /// inactivity deadline below rest on frame arrival, since an empty frame would refresh | ||
| /// the clock while advancing nothing. | ||
| /// (ADR 005 §`cdn/client/v1`). The non-empty floor keeps every frame a unit of progress, | ||
| /// so a run of empty frames cannot drive this loop without advancing the byte counter. | ||
| /// |
There was a problem hiding this comment.
Correct that it was imprecise. The ProgressReader counter tallies raw stream bytes including frame envelopes, so an empty ChunkData would move it. Reworded to the accurate invariant: the non-empty floor ties every frame to payload, so a run of empty frames cannot drive the loop while cumulative and the voucher accounting stand still.
| /// Client-only multi-source fetch scheduler (spec §5.3): fan a request across | ||
| /// several paid sources over one shared store, with bao-aligned segmentation | ||
| /// and tail-stealing. Drives [`driver::fill_gap`] per range. | ||
| mod progress; |
There was a problem hiding this comment.
Fixed — that doc was a copy of the scheduler's. It now describes ProgressReader and ThroughputFloor.
| /// which invariant they had just removed — while the requester's byte-progress stall | ||
| /// detector depends on it (#1797): an empty frame advances neither the byte counter nor the | ||
| /// voucher accounting, so a run of them would drive the receive loop without making progress. | ||
| /// That is too much weight for a convention, so the type carries the floor instead: the field |
There was a problem hiding this comment.
Same imprecision, same fix. The doc now says an empty frame advances neither the cumulative delivered bytes nor the voucher accounting, and states explicitly that the throughput floor counts wire bytes (envelopes included) — so it is this non-empty floor, not that counter, that keeps wire progress equal to content progress. The bytes field doc is reworded the same way.
Coverage reportTotal: 82.60% (was 82.56%, ▲ +0.04%) — 70754/85662 lines
History
|
…recisely (#1797) The throughput floor counts raw stream bytes, envelopes included, so an empty ChunkData would move that counter. Describe what the non-empty floor actually guarantees: every frame carries payload, so cumulative delivered bytes and voucher accounting advance with the wire. Also replace the progress module doc, which was a copy of the scheduler's, and record why `biased` cannot starve the sampler tick. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014Chu2v9AUcfr36pUVRLwwx
Closes #1797.
What
Replaces whole-frame inactivity stall detection with a byte-level windowed throughput floor across both
client-pullrequester paths (node-to-node miss pull and CLI fetch). After #1796 madeChunkDataframes sender's-choice, the old detector's resolution was one frame — too coarse: it false-tripped honest slow links on large frames and missed a slow-drip wedge.How
crates/client-pull/src/progress.rs(new):ProgressReaderwraps the QUICRecvStreamas anAsyncRead, counting bytes sub-frame into an atomic (frame-size-independent).ThroughputFlooraborts when bytes over a trailing windowWfall belowF·W(≥1 byte whenF=0⇒ idle detection).pause/resumeexclude a self-inflicted credit-window payment pause.W), steady-state (throughput floor). Thecumulative == 0split selectsPullTimeout(our own blob-size-dependent budget) vsPullStalled.classify_pull_failure'sStalledarm no longer recordsOutcome::Unreachable; it routes likeOurDeadline(meter + suppress(peer, hash), no EWMA).PullStalled/PullTimeoutstay distinct metrics.node_pull_stall_timeout_sec→node_pull_stall_window_sec(default 20) + newnode_pull_min_throughput_bps(default 4096); CLI gains--min-throughput-bps.PullDeadlines::{new,capped}take afloor_bpsarg; cap invariant is nowhard_cap > open + window.Notes
read_client_messageis not cancellation-safe (read_frameusesread_exact), so dropping it mid-frame would desynchronise framing. This was a real bug caught by the node integration suite.Testing
ProgressReadersub-frame counting;ThroughputFloor(healthy / slow-drip / full-wedge / payment-pause / F=0).PullTimeout.cargo fmt --check,cargo clippy --all-targets, and theanvil-e2ecompile gate all clean.🤖 Generated with Claude Code