Repository navigation
feat(client-pull): consumption-pace the multi-source scheduler (#1848) - #2110
Conversation
Thread a ConsumptionPacing seam through multi_source_fetch to its per-lane workers, so a Streamer can bound a multi-source fetch to one read-ahead window ahead of a live consumer's read cursor — the keystone that lets the Downloader and Streamer become two configs over the one multi-source core instead of two engines. fill_gap already took `downstream` + `pacing_wait`; the scheduler just didn't pass them. Now multi_source_fetch (and run_worker) take `pacing: Option<&ConsumptionPacing>` and thread it to each worker's fill_gap. A WindowPacer then gates every lane against the shared consumer cursor: a lane whose delivered frontier runs a window past the cursor waits until the consumer reads more. `None` (every existing caller) keeps the eager, unbounded fan-out verbatim — the whole existing scheduler suite is unchanged. Test: a 1-lane fetch under WindowPacer + an injected consumer cursor completes byte-identical ONLY by parking on a full window and being unstuck via the pacing hook (proven to fail with cursor=0 when the seam is not threaded). Follow-up (Phase 2): the Streamer replaces its single-source drive with this consumption-paced multi_source_fetch (candidate failover + small-cap fan-out). Part of the Downloader/Streamer core-unification (spec 2026-09-22-multi-source-core-and-face-unification-design). Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The pacing seam is correctly threaded to fill_gap, defaults to the prior behavior for existing callers, and is covered by a targeted end-to-end scheduler test.
Review effort: Lite
Findings: None
What changed in this PR
This PR adds an optional “consumption pacing” seam to the client-pull multi-source scheduler, allowing multi_source_fetch to be bounded to a live consumer’s read cursor (read-ahead window) when used with WindowPacer. This is a key plumbing step toward unifying the Downloader/Streamer over the same multi-source core while keeping existing eager/unbounded behavior unchanged for all current callers.
Changes:
- Thread
pacing: Option<&ConsumptionPacing>frommulti_source_fetchdown into each worker’sfill_gapcall (hook + downstream frontier reader). - Introduce the public
ConsumptionPacingstruct (downstream frontier getter +PacingWait) and re-export it fromclient-pull. - Add an end-to-end scheduler test proving that
WindowPaceractually parks and resumes via the injected pacing hook; update CLI fetch to passNone.
| File | Description |
|---|---|
| crates/client-pull/src/scheduler.rs | Adds ConsumptionPacing, threads optional pacing into workers, and adds an integration test for window gating. |
| crates/client-pull/src/lib.rs | Re-exports ConsumptionPacing from the crate root alongside the scheduler API. |
| crates/cli/src/commands/fetch.rs | Updates the multi_source_fetch call site to pass None for the new pacing parameter. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Stacked on #2108 (base = its branch, so this diff is only the scheduler change). Phase 1 of the Downloader/Streamer core-unification follow-up.
What & why
Threads a
ConsumptionPacingseam throughmulti_source_fetchto its per-lane workers, so a fetch can be bounded to one read-ahead window ahead of a live consumer's read cursor. This is the keystone that lets theDownloaderandStreamerbecome two configs over the one multi-source core (fan-out + tail-steal + shared-pool failover) instead of two engines.fill_gapalready tookdownstream+pacing_wait; the scheduler just didn't pass them. Nowmulti_source_fetch(andrun_worker) takepacing: Option<&ConsumptionPacing>and thread it to each worker'sfill_gap. AWindowPacerthen gates every lane against the shared consumer cursor: a lane whose delivered frontier runs a window past the cursor waits until the consumer reads more.None— every existing caller — keeps the eager, unbounded fan-out verbatim; the entire existing scheduler suite is unchanged.Test
A 1-lane fetch under
WindowPacer+ an injected consumer cursor completes byte-identical only by parking on a full window and being unstuck via the pacing hook. Verified to fail (cursor=0) when the seam is not threaded, so the test genuinely exercises the plumbing end-to-end.Follow-ups (per the design spec)
Streamerreplaces its single-sourcedrivewith this consumption-pacedmulti_source_fetch(candidate failover + small-cap fan-out).Downloaderreshaped onto the shared core (uncapped fan-out + dedup pre-seed) as a wrapper over theStreamercore.bundle pull→Downloader,decdn fetch -o -→Streamer,decdn fetch -o file→Downloader), behavior-preserving.Design spec:
~/Workspace/decdn/specs/2026-09-22-multi-source-core-and-face-unification-design.md(outside the repo, per the specs-stay-out rule).🤖 Generated with Claude Code