Skip to content

feat(client-pull): consumption-pace the multi-source scheduler (#1848) - #2110

Merged
alpergundogdu merged 1 commit into
claude/trusting-raman-1b3304from
claude/multi-source-consumption-pacing
Sep 22, 2026
Merged

alpergundogdu merged 1 commit into
claude/trusting-raman-1b3304from
claude/multi-source-consumption-pacing

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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 ConsumptionPacing seam through multi_source_fetch to 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 the Downloader and Streamer become two configs over the one multi-source core (fan-out + tail-steal + shared-pool failover) 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 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)

  • Phase 2: the Streamer replaces its single-source drive with this consumption-paced multi_source_fetch (candidate failover + small-cap fan-out).
  • Phase 3: Downloader reshaped onto the shared core (uncapped fan-out + dedup pre-seed) as a wrapper over the Streamer core.
  • Phase 4: CLI rewiring (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

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]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 11:41

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

🟢 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> from multi_source_fetch down into each worker’s fill_gap call (hook + downstream frontier reader).
  • Introduce the public ConsumptionPacing struct (downstream frontier getter + PacingWait) and re-export it from client-pull.
  • Add an end-to-end scheduler test proving that WindowPacer actually parks and resumes via the injected pacing hook; update CLI fetch to pass None.
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.

@alpergundogdu
alpergundogdu merged commit a89cf06 into claude/trusting-raman-1b3304 Sep 22, 2026
1 check passed
@alpergundogdu
alpergundogdu deleted the claude/multi-source-consumption-pacing branch September 22, 2026 12:44
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