Repository navigation
fix(cache): seed eviction recency from the on-disk store at open - #2261
Conversation
eviction_candidates reads only access_times, which open left empty and only traffic filled. After a restart, blobs already on disk were never candidates, so eviction starved above target and released only the working set it had just served. open now seeds access_times from iter_hashes at one instant older than any post-open access. A failed walk logs a WARN and leaves the map unseeded; open still succeeds. last_accessed (and the evict --dry-run preview) report no access for a seeded entry. Closes #2221 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit 1330a87 in the Show a line coverage summary of the most impacted files.
Updated |
Review: approve with nitsFixes #2221: every Findings
Nits
|
Decisions on the review findings
|
A failed store walk at open left eviction blind to pre-restart blobs with only a WARN to show for it; evictions_starved cannot signal it at startup. Count it in decdn_cache_recency_seed_failures_total, log the seeded count on success, and list the failure as a starvation cause. The evict dry-run prints last_accessed=none_since_start, since a blob hot before a restart has no access record either. ADR 040 and the EvictPreview docs no longer describe recency as empty on boot. Add a driver test that a restarted over-limit cache evicts on its first tick instead of starving, and a test that operator-evicted blobs stay out of the seed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y size A blob still carrying the open-time recency seed ranked oldest while a serve streamed it, because deliver and serve_leg recorded the access only at StreamEnd. Add CacheEngine::touch_recency (recency only, no frequency sighting) and call it when both serve paths start. Seeded blobs share one instant, so LRU and TinyLFU now break equal recency largest first, reaching the target in fewer releases. Add a TinyLFU ranking test for a touched vs untouched pre-open blob, a test that a partial on disk at open is a releasable candidate, and tie-break tests for both policies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
eviction_candidatesreads onlyaccess_times, whichopenleft empty and only traffic filled. After a restart, blobs already on disk were never candidates: eviction released only the working set it had just served, starved above target (evictions_starved~1/s on lon1), and on fra1 deleted a blob mid-delivery.opennow seedsaccess_timesfromiter_hashes(the same walk the DHT cold-start seed uses) at one instant (COLD_SEED_AGE= 1 s before open) older than any post-open access, so unaccessed pre-restart blobs rank first under LRU and first among equal frequency under TinyLFU. Pin / probe-hold / deny filtering ineviction_candidatesis unchanged; operator-evicted hashes stay out becauseiter_hashesskips refused hashes.decdn_cache_recency_seed_failures_totalcounter, and leaves the map unseeded;openstill succeeds. A dedicated counter is needed becauseevictions_starvedfires only once the cache is over high water, and not at all if post-open traffic supplies candidates. A successful seed logs the seeded count at INFO.last_accessedand the evict dry-run preview report none for them. The CLI dry-run printslast_accessed=none_since_start(wasnever), since a blob hot before a restart also has no record.deliverandserve_legcall the newCacheEngine::touch_recency(recency only, no frequency sighting) when a serve starts, so a seeded blob does not rank oldest while it streams. The in-flight session guard below remains the full fix.EvictPreview/EvictionPreview, thesweepandevictions_starveddocs, two DHT-seed comments, and several engine docs.Test plan
a_blob_on_disk_before_open_is_an_eviction_candidate: candidate after reopen with no touch, and releasable viarelease_for_eviction(fails without the seed)a_touched_blob_ranks_after_an_untouched_pre_open_blob: also assertsLruEvictionreleases the untouched blob first (fails without the seed)a_seeded_blob_reports_no_last_access,a_pinned_pre_open_blob_is_not_a_candidate,an_evicted_pre_open_blob_is_not_seededrestarted_over_limit_cache_evicts_without_traffic(node driver): first tick after a restart evicts,evictions_starvedstays 0 (fails without the seed)tinylfu_ranks_a_touched_blob_after_an_untouched_pre_open_blob,a_partial_blob_on_disk_before_open_is_an_eviction_candidate, and size tie-break tests for both policiescargo nextest run -p decdn-cache(488 passed); fulldecdn-node(1508 passed);decdn-clinode/dry-run (152 passed); client public-API snapshotcargo clippy --workspace --all-targets -- -D warnings,cargo fmt -- --check,cargo docwith-D warningsdecdn_cache_evictions_starved_totalstays at 0 on a node restarted above high water with unpinned content;decdn_cache_recency_seed_failures_totalstays at 0Closes #2221
🤖 Generated with Claude Code