Skip to content

fix(client,cli): grow a draining lane up to its free stream permits and free idle ones (#2252) - #2293

Merged
thiras merged 3 commits into
mainfrom
fix/2252-growth-retry-no-candidate
Oct 2, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2252-growth-retry-no-candidate

Conversation

@thiras

@thiras thiras commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What

In decdn bundle pull, a range-deduped entry's complement (147 runs, 2.4 GiB of Mistral's consolidated.safetensors) drained one request at a time on one holder. It finished 15–298 s after the last shard. This PR makes a busy lane take extra streams for its queued runs, up to the provider's free --max-lane-streams permits.

Closes #2252.

Root cause (reproduced on HEAD 41b6830d)

  • Growth never re-ran. A lane's own worker takes queued ranges one after another without ending, so no worker end asks for growth. The first growth pass runs as lanes start, before any worker holds a range. It found no busy lane to ask, so it reported no_candidate, and Growth::passed armed the retry only on refused. The HEAD run had 0 extra-stream grants for the complement, and its legs opened at strictly increasing offsets.
  • Coalescing is not the lever. The gaps between complement runs are spliced tensors: median 102 MiB, p25 27 MiB. Merging gaps up to 16 MiB cuts 147 requests to 130 and pays 3% more bytes. A fit of the bcl legs gives 0.33 s fixed cost per leg plus about 12 MiB/s per stream. So the tail is one stream's throughput, not request cost.

Changes

  1. Retry while no lane can be asked (74a0e2f1). A pass that leaves ranges with no lane to ask, while a running lane has a LaneWiden, retries after GROWTH_RETRY.
  2. First streams beat extra streams (74a0e2f1). LaneWiden's grow hook takes a new GrowFor { Restart, Extra } and grants one stream (public API change; the snapshot is updated). At --max-lane-streams ≥ 3, an extra stream leaves the provider's last free permit, so a sibling entry's first lane can still open. A restart may take that permit. Without this, a live run had extras take every bcl permit, so the complement's first lane to bcl could not open and the complement fell back to slow pull-through.
  3. No one-extra-per-lane cap (5e815eec). Work::widened is gone. The LaneWiden grant bounds a lane's extra streams, and one growth pass keeps asking a lane until it refuses. ADR 039's concurrency invariants, § Parameters and acceptance criterion 5 now say the caller's grant bounds a source's additional streams. A fetch with no grant (decdn fetch, the node) is unchanged.
  4. An idle lane gives its permit back (ce10c78e). A lane's own worker with nothing to take parks until a peer's range drains, and its lease lived in the worker future, so an idle lane held its provider permit for its whole fetch. In run 5 below, the last shard's idle bcl lane held a bcl permit for about 4 min while the complement waited. A parked own worker of a lane with a LaneWiden now gives its lease or restart grant back, and takes a stream again through grow(GrowFor::Restart) before its next pick.
  5. Less log noise. a queued range waits for a stream logs at info on the first wait and then at most every 30 s. Changes in between log at debug.

Live runs (Mistral 9194000d…, VPN off; every run had 0 failures and the same byte counts: 17.1 GB downloaded → 29.0 GB reconstructed)

run build wall last shard → last complement leg last shard → complement done
1 HEAD 41b6830d 619 s ~176 s 218 s
3 changes 1+2 744 s — 240 s
4 changes 1–3 386 s ~0 s 17 s
5 changes 1–3 653 s ~75 s 117 s
6 all changes 377 s 19 s 57 s
7 all changes 374 s 26 s 63 s
8 all changes 417 s 53 s 89 s
  • About 40 s of every "complement done" time is the last runs landing plus the whole-file BLAKE3 check of 13.5 GiB. It was 42 s on HEAD too, so it is not stream starvation.
  • In runs 6–8, complement legs open at up to 48–57 per minute once the shards are done. On HEAD the rate was about 13 per minute.
  • No entry logged a blocked lane build (every stream permit … is taken), and there were no WARN or ERROR lines.

Reviewer notes

  • Read first: Growth::passed and GrowthPass.growable, the growth-pass block in acquire (refused_lanes), GrowFor / LaneWiden, Hold::park / Hold::stream and their call in run_worker, and ExtraPermits::grant / LaneStreamCap::extra_keep.
  • A parked worker that finds no free permit ends when no lane holds work. Otherwise it tries again on a peer's progress or after GROWTH_RETRY. While it waits it still counts as an idle taker in growth_wanted.
  • At --max-lane-streams 2 no permit is kept back. There, the lease plus one extra fill the cap, and keeping one back would turn extras off.
  • Bundle pull polls every entry on one task, and grant never awaits, so no sibling can take a permit between the count and the take.
  • Not added: a test with two extras outliving their lane. The cool-once rule lives in the charged set, which this PR does not touch, and an_outage_charges_the_node_once already covers it.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-client -p decdn-cli: 1402 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • decdn-client public-api snapshot: updated for GrowFor and the LaneWiden::new signature
  • pre-commit hooks on both commits
  • New tests fail with their fix disabled:
    • a_queue_one_lane_drains_grows_an_extra_stream: 4 strictly serial legs before the fix; with the fix, 3 legs overlap and one pass opens both extras.
    • a_pass_retries_while_a_lane_can_still_grow
    • a_busy_lane_runs_as_many_extra_streams_as_granted
    • a_cap_of_two_still_grants_an_extra_stream
    • a_parked_lane_gives_its_stream_back: before the fix, the lease was held while the peer lane drained.
    • The restart and extra call sites are pinned by GrowFor recording; swapping either fails a test.
    • Restoring "ask each lane once per pass" or a one-extra cap fails a test.
  • CHANGELOG entry under Fixed

🤖 Generated with Claude Code

thiras and others added 2 commits October 2, 2026 10:44
… a sibling (#2252)

A lane's own worker takes queued ranges one after another without ending,
so no worker end asked for growth. The first growth pass runs as lanes
start, before any worker holds a range, so it found no busy lane to ask
and armed no retry. A range-deduped complement then drained as one serial
request per run. A pass that leaves ranges with no lane to ask, while a
running lane has a LaneWiden, now retries after GROWTH_RETRY.

Once growth fired, extra streams took every --max-lane-streams permit of a
provider and a sibling entry's first lane could not open. LaneWiden's grow
hook now takes a GrowFor (Restart or Extra) and grants one stream; at a
cap of 3 or more an extra stream leaves the provider's last free permit,
and a restart may take it.

The "a queued range waits for a stream" line logs at info on the first
wait and then at most every 30 s; changes in between log at debug.

Refs #2252

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#2252)

A busy lane ran at most one extra stream, and a growth pass asked each lane
once. In bundle pull the --max-lane-streams permits already bound the
streams to one provider, so the cap only held a range-deduped complement
at two streams of ~10 MiB/s once the shards finished, with the client
link underused. Drop the per-lane cap (Work::widened): the LaneWiden grant
bounds a lane's extra streams, and one pass keeps asking a lane that grants
until it refuses, so it fills every free permit. A fetch without a
LaneWiden runs no extra stream, as before. ADR 039 now states that the
caller's grant bounds a source's additional streams.

Refs #2252

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 08:23
@thiras thiras self-assigned this Oct 2, 2026

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

🔵 Needs a closer look

The change alters concurrent scheduling, permit accounting, and payment-lane behavior and warrants final human review.

Review effort: Balanced
Findings: None

What changed in this PR

This PR reduces serial bundle-pull tails by allowing busy lanes to consume multiple available stream permits.

Changes:

  • Retries lane growth when queued work initially has no candidate.
  • Distinguishes restart and extra-stream grants while reserving sibling capacity.
  • Updates tests, public API, ADR, and release notes.
File Description
crates/​client/​src/​scheduler.rs Implements multi-stream lane growth and retries.
crates/​client/​src/​streamer.rs Updates lane-widening documentation.
crates/​client/​src/​lib.rs Exports GrowFor.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Updates the public API snapshot.
crates/​cli/​src/​commands/​cli_sources.rs Documents reserved stream capacity.
crates/​cli/​src/​commands/​bundle_pull.rs Enforces provider permits for extras and restarts.
adr/​039-multi-source-parallel-fetch.md Revises concurrency invariants.
CHANGELOG.md Records the scheduling fix.

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

@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit ce10c78 in the fix/2252-growth-retr... branch remains at 87%, unchanged from commit 41b6830 in the main branch.

Show a line coverage summary of the most impacted files.
File main 41b6830 fix/2252-growth-retr... ce10c78 +/-
crates/node/src.../client/wire.rs 96% 95% -1%
crates/cache/src/engine.rs 95% 94% -1%
crates/node/src/dht/publish.rs 92% 92% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/cli/src/.../bundle_pull.rs 81% 81% 0%

Updated October 02, 2026 09:09 UTC

…2252)

A lane's own worker that finds nothing to take parks until a peer's range
drains, and its lease guard lived in the worker future, so a parked lane
kept its provider's --max-lane-streams permit for the rest of its fetch.
In a Mistral bundle pull the last shard's idle bcl lane held a bcl permit
for about four minutes while the complement queue on bcl waited for it.

A parked own worker of a lane with a LaneWiden now gives its lease or
restart grant back as it parks, and takes a stream again through
grow(GrowFor::Restart) before its next pick. With no stream free it ends
when no lane holds work, and otherwise tries again on a peer's progress
or after GROWTH_RETRY.

Refs #2252

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras changed the title fix(client,cli): grow a draining lane up to its free stream permits (#2252) fix(client,cli): grow a draining lane up to its free stream permits and free idle ones (#2252) Oct 2, 2026
@thiras
thiras merged commit 8c44072 into main Oct 2, 2026
30 checks passed
@thiras
thiras deleted the fix/2252-growth-retry-no-candidate branch October 2, 2026 09:13
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.

bundle pull: a range-dedup complement still drains as 147 serial requests to one holder and sets every run's finish time

2 participants