Skip to content

refactor(node): remove client-less background cache-warm (#1610) - #1611

Merged
alpergundogdu merged 2 commits into
mainfrom
feat/1610-remove-clientless-warm
Aug 5, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
feat/1610-remove-clientless-warm

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1610.

What

Removes the detached background cache-warm — both variants (paid node→node and unpaid own-backend). Net −965 lines.

Why

The background warm re-pulled a blob from offset 0 after a serve-miss whose foreground pull missed its deadline or couldn't open — after the client had already been refused. The paid variant is an economic attack surface: unpaid egress forces paid ingress. A requester forces the foreground miss, pays nothing, and leaves the node paying an upstream from zero for a blob nobody wants; repeated, it drains payment-channel deposits. The unpaid variant is the same shape against backend (S3/R2) egress.

This is not a scale-deferral cut — the economics are wrong at any node count.

The invariant this establishes

A node ingests only while a live client is waiting on the bytes. It never initiates a from-zero pull speculatively.

Kept (unchanged)

The foreground, client-waiting fills: the serve-miss tee (open_progressive_pull), buffered populate / populate_local bounded by the pull-through deadline, and the node_pull_through_timeout / node_pull_through_error metrics. Advertising is independent — the node announces assigned content from the HEAD/stat metadata index, not from warmed bytes — so what the node serves does not change.

Removed

maybe_spawn_background_fill, spawn_local_warm, the BackgroundFill subsystem + its MiB semaphore permit pool (MAX_BACKGROUND_FILL_MB, warm_budget_mb), BACKGROUND_FILL_HARD_CAP, the WarmOutcome / WarmVerdict accounting, the 7 node_pull_through_background_* metrics, the pull_through_bg_shutdown wiring, and 9 inline unit tests. The permit pool gated only background warms, so the foreground path needed no retuning.

Doc sweep

The background warm was load-bearing in a lot of rationale prose across node, common, and client-pull (deadline/drop-path reasoning). All of it — comments that named the deleted symbols or asserted "on expiry the transfer continues in a detached warm" — was rewritten to the post-removal reality (clean miss, nothing continues). Zero references to any deleted symbol remain.

Verification

cargo build -p decdn-node
cargo nextest run -p decdn-node          # 961 passed, 0 skipped
cargo clippy -p decdn-node -p decdn-common -p decdn-client-pull --all-targets -- -D warnings
cargo fmt -- --check
RUSTDOCFLAGS='-D warnings' cargo doc -p decdn-node -p decdn-common -p decdn-client-pull --no-deps --document-private-items

All clean.

Context

This unblocks the node leg of the PeerSource unification (unify the paid-pull loop across the node + both CLI legs) — with the client-less warm gone, a refactored PeerSource never has to support a paid pull with no consumer.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Behavior Changes

    • Removed detached background cache warming after client pull-through timeouts or misses.
    • Pull requests now end cleanly at the configured foreground deadline without starting follow-up cache fills.
    • Simplified shutdown and timeout handling for pull-through operations.
  • Metrics

    • Removed metrics that tracked background cache-warming activity.
  • Documentation

    • Clarified timeout, cancellation, shutdown, and pull-through behavior across client and node operations.

The detached background warm re-pulled a blob from offset 0 after a serve-miss
whose foreground pull missed its deadline or could not open — after the client
had already been refused. The paid variant is an economic attack surface:
unpaid egress forces paid ingress, so a requester can force the foreground miss,
pay nothing, and leave the node paying an upstream from zero for a blob nobody
wants; repeated, it drains payment-channel deposits. The unpaid variant is the
same shape against backend egress.

Removing both establishes the invariant: a node ingests only while a live client
is waiting on the bytes; it never initiates a from-zero pull speculatively. The
foreground client-waiting fills (serve-miss tee, buffered populate under the
pull-through deadline) are unchanged; advertising is independent (HEAD/stat
metadata index), so what the node serves does not change.

Deletes: maybe_spawn_background_fill, spawn_local_warm, the BackgroundFill
subsystem + its MiB permit pool, MAX_BACKGROUND_FILL_MB, the
node_pull_through_background_* metrics, and the pull_through_bg_shutdown wiring.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 5, 2026 13:00
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 3e6173e5-8666-442b-989e-29f2c7895b3c

📥 Commits

Reviewing files that changed from the base of the PR and between f98d771 and 29729b4.

📒 Files selected for processing (1)
  • crates/node/src/handlers/client/mod.rs

Walkthrough

The pull path removes detached background cache warming, its runtime lifecycle, and its metrics. Foreground timeout and fault paths now return directly. Documentation and tests describe the updated deadline and cancellation behavior.

Changes

Background cache-fill removal

Layer / File(s) Summary
Remove background-fill handler paths
crates/node/src/handlers/client/fill.rs, crates/node/src/handlers/client/mod.rs, crates/node/src/handlers/client/window.rs, crates/node/tests/*
Client handlers no longer spawn detached fills after misses or timeouts. Background-fill state, helpers, constants, and related tests are removed.
Remove runtime background-fill lifecycle
crates/node/src/runtime/mod.rs
Runtime setup and shutdown no longer create, wire, transfer, or cancel the background-fill shutdown token.
Remove background-fill metrics
crates/node/src/metrics.rs
Background pull-through counters and recorder methods are removed.
Align pull and timeout documentation
crates/client-pull/src/*, crates/common/src/cli/fetch.rs, crates/node/src/chain_events/resumable_watcher.rs, crates/node/src/node_origin/mod.rs, crates/node/src/selection.rs, crates/node/tests/*
Comments and documentation now describe foreground deadlines, dropped serve futures, slow first-byte attribution, and the removal of detached warming.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ClientHandler
  participant Origin
  Client->>ClientHandler: Request pull
  ClientHandler->>Origin: Start foreground pull
  Origin-->>ClientHandler: Return timeout or fault
  ClientHandler-->>Client: Return error without background fill
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.31% (was 80.29%, ▲ +0.02%) — 57032/71016 lines

File Coverage Lines Δ
crates/client-pull/src/ledger.rs 99.79% 465/466 ● 0.00%
crates/client-pull/src/lib.rs 90.15% 1428/1584 ● 0.00%
crates/common/src/cli/fetch.rs 100.00% 150/150 ● 0.00%
crates/node/src/chain_events/resumable_watcher.rs 90.01% 748/831 ● 0.00%
crates/node/src/handlers/client/fill.rs 66.21% 96/145 ▲ +9.86%
crates/node/src/handlers/client/mod.rs 89.08% 522/586 ▼ 0.36%
crates/node/src/handlers/client/window.rs 62.99% 257/408 ▲ +0.06%
crates/node/src/metrics.rs 95.67% 1105/1155 ● 0.00%
crates/node/src/node_origin/mod.rs 93.04% 1030/1107 ● 0.00%
crates/node/src/runtime/mod.rs 46.61% 1094/2347 ▲ +0.24%
crates/node/src/selection.rs 97.29% 430/442 ● 0.00%
History
Commit Total Δ vs base
f98d771 80.31% ▲ +0.02%
29729b4 (HEAD) 80.31% ▲ +0.02%

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.

🟢 Ready to approve

The background-warm removal appears complete (no remaining symbol references) with only a minor test-helper naming nit to consider.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR removes the node’s detached, client-less background cache-warm paths (both paid peer pulls and unpaid local-origin warms) to enforce the invariant that ingestion only happens while a live client is waiting on bytes, eliminating an economic/cost-amplification attack surface.

Changes:

  • Deleted the background-fill subsystem, its shutdown wiring, and its metrics/counters.
  • Simplified the serve-miss paths to return a clean miss on deadline expiry without spawning any detached follow-up work.
  • Updated rationale/comments and adjusted tests to match the new “nothing continues after refusal” behavior.
File summaries
File Description
crates/node/tests/node_origin_pull.rs Updates test commentary about cancellation/drop paths after removing detached warms.
crates/node/tests/client_loopback.rs Clarifies that only foreground deadlines can fill the store; no background warm can mask failures.
crates/node/src/selection.rs Updates outer-deadline rationale docs to reflect that no background acquisition continues.
crates/node/src/runtime/mod.rs Removes background-fill wiring, shutdown token, and associated runtime construction logic.
crates/node/src/node_origin/mod.rs Updates documentation about what external events drop in-flight pulls now that warm/shutdown hooks are gone.
crates/node/src/metrics.rs Removes background-fill metrics fields and recorder hooks.
crates/node/src/handlers/client/window.rs Stops spawning background fills on miss/timeout in the serve path.
crates/node/src/handlers/client/mod.rs Deletes the BackgroundFill types/helpers and prunes related tests; keeps handler tests with a simplified helper.
crates/node/src/handlers/client/fill.rs Removes maybe_spawn_background_fill and local-origin warm spawning; updates timeout semantics to “clean miss”.
crates/node/src/chain_events/resumable_watcher.rs Removes references to WarmOutcome precedent in panic-guard docs.
crates/common/src/cli/fetch.rs Removes mention of mirroring node’s background hard cap in CLI timeout documentation.
crates/client-pull/src/lib.rs Updates commentary that previously referenced background warm behavior.
crates/client-pull/src/ledger.rs Updates commentary describing which external drops can end a pull.
Review details
  • Files reviewed: 13/13 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread crates/node/src/handlers/client/mod.rs Resolved
The warm/background-fill tests it was named for were removed in this PR;
the fixture is now a generic minimal ClientHandler builder.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 6421881 into main Aug 5, 2026
24 checks passed
@alpergundogdu
alpergundogdu deleted the feat/1610-remove-clientless-warm branch August 5, 2026 13:07
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.

Remove speculative client-less background warm (unpaid-egress → paid-ingress deposit-drain surface)

2 participants