Repository navigation
fix(client,cli): grow a draining lane up to its free stream permits and free idle ones (#2252) - #2293
Merged
Merged
Conversation
… 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]>
There was a problem hiding this comment.
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.
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit ce10c78 in the Show a line coverage summary of the most impacted files.
Updated |
…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]>
3 tasks
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.
What
In
decdn bundle pull, a range-deduped entry's complement (147 runs, 2.4 GiB of Mistral'sconsolidated.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-streamspermits.Closes #2252.
Root cause (reproduced on HEAD
41b6830d)no_candidate, andGrowth::passedarmed the retry only onrefused. The HEAD run had 0 extra-stream grants for the complement, and its legs opened at strictly increasing offsets.Changes
74a0e2f1). A pass that leaves ranges with no lane to ask, while a running lane has aLaneWiden, retries afterGROWTH_RETRY.74a0e2f1).LaneWiden's grow hook takes a newGrowFor { 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.5e815eec).Work::widenedis gone. TheLaneWidengrant 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.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 aLaneWidennow gives its lease or restart grant back, and takes a stream again throughgrow(GrowFor::Restart)before its next pick.a queued range waits for a streamlogs 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)41b6830devery stream permit … is taken), and there were no WARN or ERROR lines.Reviewer notes
Growth::passedandGrowthPass.growable, the growth-pass block inacquire(refused_lanes),GrowFor/LaneWiden,Hold::park/Hold::streamand their call inrun_worker, andExtraPermits::grant/LaneStreamCap::extra_keep.GROWTH_RETRY. While it waits it still counts as an idle taker ingrowth_wanted.--max-lane-streams2 no permit is kept back. There, the lease plus one extra fill the cap, and keeping one back would turn extras off.grantnever awaits, so no sibling can take a permit between the count and the take.chargedset, which this PR does not touch, andan_outage_charges_the_node_oncealready covers it.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-client -p decdn-cli: 1402 passedRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemsdecdn-clientpublic-api snapshot: updated forGrowForand theLaneWiden::newsignaturea_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_growa_busy_lane_runs_as_many_extra_streams_as_granteda_cap_of_two_still_grants_an_extra_streama_parked_lane_gives_its_stream_back: before the fix, the lease was held while the peer lane drained.GrowForrecording; swapping either fails a test.🤖 Generated with Claude Code