Repository navigation
refactor(cache): move the eviction driver loop from the node into decdn-cache - #2886
Merged
Merged
Conversation
…dn-cache The driver is generic over the cache engine, so any binary that owns a CacheEngine can hold it under its disk-aware ceiling. The caller injects the free-disk probe and a callback for each released hash; the node passes its statvfs probe and the ADR 041 warming-allowance forget. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟢 Approval recommended
The eviction driver refactor is accompanied by updated node wiring plus adjusted cache tests and documentation to match the new callback-based API, with no remaining issues noted in the review evidence.
No open issues 🎉
What changed in this PR
Moves the cache eviction driver loop from decdn-node into decdn-cache so other binaries (e.g., decdn gateway) can reuse the same eviction behavior without node-only dependencies.
Changes:
- Introduces
decdn_cache::eviction_driver::runand re-exportsEvictionParamsfrom the cache crate root. - Replaces node-only dependencies with injected callbacks: a
free_spaceprobe and anon_releasehook. - Updates node wiring, cache tests, and documentation to match the new module location and API.
| File | Description |
|---|---|
| crates/node/src/runtime/mod.rs | Updates the node runtime to invoke decdn_cache::eviction_driver::run, injecting the free-space probe and warming release callback to preserve existing behavior. |
| crates/cache/src/lib.rs | Exposes the new eviction_driver module publicly and re-exports EvictionParams, updating crate-level docs to reference the new entrypoint. |
| crates/cache/src/eviction_driver/tests.rs | Adjusts eviction driver tests to the callback-based API and adds/updates assertions around the on_release hook behavior. |
| crates/cache/src/eviction_driver.rs | Moves the eviction driver loop into decdn-cache and refactors the API to accept injected free_space and on_release functions instead of node-specific inputs. |
| CLAUDE.md | Updates project documentation to reflect that the eviction driver loop now lives in decdn-cache and uses injected inputs. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
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.
Second step of moving the
decdn gatewaycache ontodecdn-cache(#2881, after #2884). The gateway needs the same eviction loop the node runs, so the loop moves into the cache crate.What changes
crates/node/src/runtime/eviction.rsbecomesdecdn_cache::eviction_driver.run,EvictionParams(re-exported at the crate root) and the tick, sweep, pending-reclaim and hysteresis logic are unchanged.free_space: impl FnMut() -> anyhow::Result<u64>replaces thecache_dirpath and the directdecdn_common::diskcall.decdn-cachegains no dependency ondecdn-common.on_release: impl Fn(Hash)replaces theWarmingAllowanceargument. It runs once per hash after a successful release.statvfs_target(cache_dir).availas the probe andwarming.forgetas the callback, so its behaviour is the same.sweep_orders_via_injected_policynow also checks thaton_releasesees exactly the released hash.Tests
cargo nextest run -p decdn-cache -p decdn-node: pass. The 17 driver tests now run underdecdn-cache.cargo clippy --workspace --all-targets --all-featuresand-p decdn-cache --no-default-features --all-targets: clean, with warnings denied.cargo doc --workspace --no-deps --document-private-items,check_crate_edges.py,cargo fmt --check: pass.cargo deny check advisoriesstill fails oncrypto-bigint(RUSTSEC-2026-0387) andpin-utils(RUSTSEC-2026-0441), the same as main.🤖 Generated with Claude Code