Repository navigation
fix(client): prime a streamed fetch's size open at the streamed drive's first leg - #2673
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Active issues cause empty-blob streams without size hints to reject valid holders and capped range streams to reopen identical spans, retaining the duplicate-open cost.
2 open issues
What changed in this PR
This PR addresses #2644 by aligning a streamed fetch’s size-discovery open with its first transfer leg, avoiding an extra open when no size hint is available.
Changes:
- Adds whole-download and streamed first-leg selection, with shared pacing and read-ahead calculations.
- Primes size-discovery pulls for adoption by streamed transfers.
- Adds regression coverage and documents the behavior.
| File | Description |
|---|---|
crates/e2e/tests/peer_store_probeless.rs |
Adds a probe-less stdout streaming journey that checks pull adoption. |
crates/client/src/streamer.rs |
Shares the stream pacer constructor. |
crates/client/src/lane_sources.rs |
Opens and primes the selected first leg for size discovery. |
crates/client/src/driver/tests.rs |
Tests first-leg prediction and primed-pull adoption. |
crates/client/src/driver.rs |
Predicts the first streamed leg on an empty store. |
crates/client/src/bundle/engine.rs |
Explicitly selects whole-blob size opens. |
crates/cli/src/commands/fetch.rs |
Selects streamed legs and shares read-ahead resolution. |
CHANGELOG.md |
Records the streamed size-open fix. |
adr/039-multi-source-parallel-fetch.md |
Documents first-leg size discovery and pull reuse. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
…'s first leg With no size hint, `LaneSources::first_claim` read the size from a whole-blob open and primed that pull for the drive's first leg. A streamed drive (`decdn get -o -`, a gateway pull with no size) cuts its first leg to the read-ahead window, so the leg never took the pull. It closed the pull and opened offset 0 again, after the node had written into the closed pull for up to a round trip. `first_claim` now takes the first leg the drive opens (`FirstLeg`). A streamed size open pulls `streamed_first_leg`, which the window pacer's first draw on a fresh state and the drive's own leg cut define, so the open and the drive cannot drift. It opens the leg as if the blob runs past it, primes the leg recomputed at the signed size, and falls back to a whole open for a window that starts past the end. A download still opens the whole blob. Closes #2644 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed leg at the store size A holder serves the empty blob only whole and refuses any other range of it with `Declined`, which is not a past-end fault, so a no-hint streamed fetch of it dropped every holder. Its size open is now the whole open. The streamer sizes its store at the size the cap on held bytes lets the window reach, and a drive leg's range carries that size, so a primed leg keyed at the signed size was never adopted on a blob past the cap. The primed leg is now built against the store's size, and still checked against the span the node served at the signed size. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras
force-pushed
the
fix/stream-prime-first-leg
branch
from
October 28, 2026 04:42
4d717c9 to
64b03b6
Compare
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
With no size hint,
LaneSources::first_claimread the size from a whole-blob open and primed that pull for the drive's first leg (PrimedSource::prime_next). A streamed drive cuts its first leg to the read-ahead window (WindowPacer), so the leg never matchedalign_range(0, 0, total). That coversdecdn get -o -on the peer-store fast path, and a gateway pull whose size lookup finds none. The drive closed the primed pull and opened offset 0 again, after the node had written into the closed pull for up to a round trip.Changes:
FirstLeg { Whole, Streamed { window, read_ahead } }is a new argument tofirst_claim. The CLI passesStreamedwhen the sink streams, with the same read-aheadstream_outuses (stream_read_ahead). The bundle engine passesWhole.driver::streamed_first_legpredicts the streamed drive's first leg on an empty store. The draw is what the streamer's own pacer (streamer::stream_pacer, now shared withStreamer) decides on a freshPaceState. The gap is the window widened to whole chunk groups, as the store reports it missing. The leg is cut byleg_range, the same function every drive leg uses.open_first_legopens that leg as if the blob runs past it (UNBOUNDED_SIZE), because the leg's end does not depend on the size while the blob is longer. It then primes the leg recomputed at the signed size, only when the pull covers exactly that span. A node clamps a pull that runs past the end, so on a shorter blob the clamped pull is the drive's first leg. A window that starts past the end (is_range_past_end) falls back to the whole open.Closes #2644
Reviewer notes
streamed_first_legincrates/client/src/driver.rs, thenopen_first_legincrates/client/src/lane_sources.rs.decdn_bytes_served_totalis identical (+64 B) and no stream counts as abandoned. The client's close reaches the node before it writes into the unadopted pull. On a WAN the waste is about bandwidth × RTT, up to a credit window. The fix also saves one open round trip per streamed fast-path fetch.peer_store_probelessstreams a 17 MiB + 1234 B blob, larger than the 16 MiB default read-ahead, to stdout on the fast path. It checks three things:probe_start_ms, so the size open ranopening a paid leg … byte_offset=0line appears, which means the drive adopted the size open's pull. Later legs do log, so the check can't pass vacuously.--max-sources 1would remove steal noise, butadmit_sourcestruncates the candidates to 1, which is below the fast path's minimum of 3, so the fetch probes and never runs a size open.fetch #2 probed the holders N time(s)fails intermittently here: 3 of 6 runs with main's unmodified test file against these binaries. Fetch docs: Generalize architecture to content-agnostic CDN, refocus slashing on bad edges #2 is a file download, whose path this PR does not touch. The fast path re-probes in the background after the lanes start, andprobes == 0races against that. Worth its own issue.lane_sourcesis#[doc(hidden)], so thedecdn-clientpublic-API snapshot is unchanged.Verification
driver/tests.rs):streamed_first_leg_is_the_range_a_streamed_drive_opens_firstpins the predictor against a realdriveunderstream_pacer, over 8 cases: whole, prefix window, and off-group offsets, with and without a length, on blobs longer and shorter than the window. It also covers past-end and the held-bytes cap.a_streamed_drive_adopts_a_pull_primed_at_its_first_leg: a pull primed at the predicted leg is adopted (one open of offset 0). One primed at the whole blob is reopened.CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-featurescargo nextest run -p decdn-client -p decdn-cli: 2353 passedpeer_store_probeless: 3/3 on the final code. Siblingscli_fetch_stdout,gateway_concurrent_pulls,gateway_pointer,gateway_public,cli_fetch_multi_source,cli_fetch_resume,cli_fetch_recovers_one_holderandcli_fetch_topup: 12/12.CARGO_BUILD_WARNINGS=deny cargo doc -p decdn-client -p decdn-cli --no-deps --document-private-itemspre-commit runon the change.cargo denyreports only the existing warn-only advisories.adr/:make -C adr check-refs🤖 Generated with Claude Code