Skip to content

fix(client,node): steal a slow leg's tail by pull-through and time serve waits (#2348) - #2357

Merged
thiras merged 2 commits into
mainfrom
fix/2348-slow-victim-steal
Oct 7, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/2348-slow-victim-steal

Conversation

@thiras

@thiras thiras commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Refs #2348.

  • Client: slow-victim steal. A steal used to require covering the victim range's last 64 MiB block (client: a lane cannot steal a victim's tail unless it covers the victim's whole range, so one partial-coverage leg runs alone #2303). In bundle pull: a 1.15 GiB leg on a 0.5 MiB/s lon1 lane runs alone for 35 min while every other lane is idle (SDXL, 2 of 2 runs) #2348 only lon1 covered it, so one 0.5 MiB/s leg ran alone for ~35 min. Now, when no covered-suffix steal qualifies, a lane that is not barred from pull-through steals the rate-weighted tail of a range on another lane running at ≤ 1/4 of its rate, measured over ≥ 30 s of active time. Its node serves the uncovered part by pull-through. Covered-suffix steals still come first, and all existing floors (MIN_SPLIT_SIZE, MIN_STOLEN, MIN_VICTIM_KEEP, victim keeps a missing byte) apply.
  • Client: parked re-check. A parked own worker re-checks every 5 s, because a victim's progress wakes no one. A check that finds no steal due takes no stream permit.
  • Client: consumer waits. Time a victim spends parked on the consumer (ended parks and the one in progress) stays out of its rate, so a paced fetch does not misread a waiting lane as slow.
  • Node: serve_stream wait breakdown. New fields: store_wait_ns, send_wait_ns, proof_wait_ns, path_kind, path_rtt_us, path_cwnd, path_congestion_events, conn_lost_packets, conn_lost_bytes, conn_sent_bytes. They are recorded on every exit of the hit (deliver_loop) and miss (serve_leg_loop) loops, cancel included. Telemetry for bundle pull: a 1.15 GiB leg on a 0.5 MiB/s lon1 lane runs alone for 35 min while every other lane is idle (SDXL, 2 of 2 runs) #2348 shows lon1 served other nodes at 30–60 MB/s per stream with an idle disk, while every lon1→client stream ran at ~1.3 MB/s aggregate (bcl→client was slow too). That is the path or client side, not lon1's store. These fields let the next run say which.
  • Docs. ADR 039 gains the slow-victim rule plus slow_victim_factor / slow_victim_evidence / steal_recheck. appendix-observability documents the new fields. CHANGELOG has Fixed and Added entries.

The node half of #2348 (why the lon1→client path is slow) stays open until a testnet run with these fields.

Test plan

  • cargo nextest run -p decdn-client -p decdn-node: 2226 passed
  • New scheduler tests: slow victim stolen by pull-through; barred lane; rate gap 2x/4x; evidence 20 s/40 s; no stealer rate; own extra; covered steal preferred; open consumer park; parked lane steals after re-check; BlobTooLarge and NotFound refusals bounded; re-check takes no stream while no steal is due. Mutation-checked: the slow-victim pass, the re-check timer, the open-park fix and the no-permit guard each fail their tests when removed.
  • Node: span fields asserted on the hit path (client_loopback) and the miss path (node_origin_pull window pull-through)
  • cargo clippy --workspace --all-targets --all-features -D warnings, cargo doc -D warnings, public-api snapshot unchanged, pre-commit
  • Testnet: SDXL bundle pull with RUST_LOG=info,decdn_client=debug. Look for kind="slow_victim" steals, and compare lon1 serve_stream send_wait_ns / proof_wait_ns / path_cwnd / conn_lost_packets

🤖 Generated with Claude Code

…rve waits (#2348)

A lane could steal only inside a range's covered suffix, so a range whose
last block only one lane covered ran on that lane to the end, however slow:
in #2348 one 0.5 MiB/s lon1 leg ran alone for 35 min while every other lane
sat idle.

Client: when no covered-suffix steal qualifies, a lane not barred from
pull-through steals the rate-weighted tail of another lane's range that runs
at a quarter of its rate or less (SLOW_VICTIM_FACTOR), measured over at
least 30 s of active time (SLOW_VICTIM_EVIDENCE, parks on the consumer left
out, the open one included). Its node serves the part outside its coverage
by pull-through. A parked own worker re-checks every 5 s (STEAL_RECHECK)
and takes no stream permit unless a steal is due. A refused steal requeues
the tail and the usual pull-through bars apply.

Node: serve_stream spans record store_wait_ns / send_wait_ns /
proof_wait_ns, the selected path's kind, RTT, cwnd and congestion events,
and connection loss/sent deltas over the serve loop, on every exit of the
hit and miss serve loops. Telemetry for #2348 points at the lon1 -> client
path, not lon1's store; these fields let the next run say which.

ADR 039 gains the slow-victim rule and its three parameters; the
observability appendix documents the new span fields.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Rate sampling has an atomic snapshot race, and hit-path exits can omit the promised telemetry fields.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds slow-leg tail stealing to reduce fetch latency and expands node serve diagnostics.

Changes:

  • Adds rate-based pull-through tail stealing and periodic parked-worker checks.
  • Records serve-loop wait and QUIC path telemetry.
  • Updates tests, ADRs, and changelog documentation.
File Description
crates/​client/​src/​scheduler.rs Implements slow-victim stealing and rate accounting.
crates/​client/​src/​source_set.rs Updates uncovered-range semantics.
crates/​node/​src/​handlers/​client/​serve_waits.rs Adds serve wait and path telemetry.
crates/​node/​src/​handlers/​client/​delivery.rs Instruments cache-hit serving.
crates/​node/​src/​handlers/​client/​serve_leg.rs Instruments pull-through serving.
crates/​node/​src/​handlers/​client/​proof_wait.rs Exposes selected-path details.
crates/​node/​src/​handlers/​client/​dispatch.rs Declares new span fields.
crates/​node/​src/​handlers/​client/​mod.rs Registers the telemetry module.
crates/​node/​tests/​support/​mod.rs Adds telemetry assertions.
crates/​node/​tests/​client_loopback.rs Verifies hit-path telemetry.
crates/​node/​tests/​node_origin_pull.rs Verifies miss-path telemetry.
adr/​039-multi-source-parallel-fetch.md Specifies slow-victim scheduling.
adr/​appendix-observability.md Documents telemetry fields.
CHANGELOG.md Records the behavior and observability changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/client/src/scheduler.rs Resolved
@github-code-quality

github-code-quality Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 1a0fe8a in the fix/2348-slow-victim... branch remains at 88%, unchanged from commit f4faa47 in the main branch.

Show a line coverage summary of the most impacted files.
File main f4faa47 fix/2348-slow-victim... 1a0fe8a +/-
crates/cli/src/...ommands/node.rs 79% 78% -1%
crates/client/s...c/connection.rs 98% 97% -1%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/node/src...ent/delivery.rs 94% 94% 0%
crates/node/src...gin/pull_leg.rs 92% 92% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...t/proof_wait.rs 96% 96% 0%
crates/node/src...nt/serve_leg.rs 91% 92% +1%
crates/node/src.../serve_waits.rs 0% 96% +96%

Updated October 07, 2026 10:43 UTC

…e setup waits (#2348)

Unit::rate_sample read `parked` then `park_open_at`, the same order
ClosePark writes them, so a park that closed between the two loads was
subtracted from neither and a victim could read as slow. Read the open
marker first with Acquire against ClosePark's Release clear: a closing park
is now left out once or twice, never not at all.

ServeWaits started after the hit loop's export and pool-funder awaits (and
the miss loop's pool-funder await), so an exit or cancel there recorded no
wait fields. Start the guard at each loop's first await, and time the
export's setup as store wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras merged commit 64e4e88 into main Oct 7, 2026
30 checks passed
@thiras
thiras deleted the fix/2348-slow-victim-steal branch October 7, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants