Repository navigation
feat(cache): add fbuild cache reclaim — on-demand, ordered cache eviction (#1750 item 3) - #1772
Merged
Merged
Conversation
…on (#1750 item 3) A full disk now has an explicit remedy that is never a build side effect. #1341 is why this is a command and not a policy: the daemon's background GC evicted a warm toolchain under a running build and the link step died on ENOENT. `fbuild cache reclaim [--needed 2G] [--dry-run] [--cache-dir DIR]` evicts disposable caches in a fixed order (toolchains -> packages -> platforms -> libraries -> frameworks -> lnk-blobs, install before archive within a kind) and stops the moment the requested byte count is free. It refuses to run while daemon_status.json reports an operation in progress, and names the operation. A missing or unparseable status never blocks: no daemon means nothing to evict out from under. The #20 safety model is reused rather than reinvented: the LRU queries filter `pinned = 0`, so a leased entry is invisible to reclaim. No new budgets and no new watermarks - the target is a byte count, and the watermarks stay the background GC's job. The four LRU queries now share one private helper so a new caller cannot drop the pin filter. The zccache object cache is the last step of #1750's order and the one fbuild cannot drive from the CLI (its LRU budget lives inside the embedded zccache service in fbuild-daemon, no cross-process trim API). A short run says so and points at `fbuild purge` instead of pretending. Tests: 9 in fbuild-packages-fetch against real files under a rooted tempdir_in (order, stop-before-next-kind, stop-inside-kind, install before archive, dry-run parity, pinned invisible, zero target, unsatisfiable target, vanished path) and 9 in fbuild-cli (mid-build refusal, idle/missing status, ordered rendering, SHORT verdict, dry-run label, empty report, size parsing). Refs #1750
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Oct 28, 2026
Merged
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.
What
fbuild cache reclaim— the on-demand, budgeted reclaim half of #1750 (item 3).A full disk now has an explicit remedy that is never a build side effect. #1341 is the
reason this is a command and not a policy: the daemon's background GC evicted a warm
toolchain under a running build and the link step died on
ENOENT.Behaviour
toolchains → packages → platforms → libraries → frameworks → lnk-blobs.Within a kind the extracted install goes before its archive — reinstalling is cheaper
than re-downloading.
whole (a target smaller than the next entry frees that entry, not part of it), and the
report states the real number.
daemon_status.jsonreports an operation in progress,and names the operation. A missing or unparseable status never blocks (no daemon = nothing
to evict out from under). This is the ci(esp32): daemon background GC evicts warm esptool install mid-build — elf2image ENOENT #1341 guard.
pinned = 0, so aleased/pinned entry (one a build is holding) is invisible to reclaim. No new budgets and no
new policy — the target is a byte count, and the watermarks stay the background GC's job.
the one fbuild cannot drive from the CLI — its LRU budget lives inside the embedded zccache
service in
fbuild-daemon, with no cross-process trim API. A short run says so and pointsat
fbuild purgeinstead of half-doing it.--neededaccepts2G/512M/1048576(reusesdisk_cache::budget::parse_human_size).Changes
crates/fbuild-packages-fetch/src/disk_cache/reclaim.rs(+reclaim_tests.rs) — new module:RECLAIM_ORDER,ReclaimStep,ReclaimReport,reclaim(); the dry run shares the walk.disk_cache/index/queries.rs— kind-filtered LRU queries (lru_installed_entries_of_kind,lru_archive_entries_of_kind). The four LRU queries now share one privatelru_entrieshelper, so the
pinned = 0filter cannot be dropped by a future caller. Existing publicqueries and SQL semantics are unchanged.
disk_cache/mod.rs—DiskCache::reclaim(needed_bytes, dry_run)facade.crates/fbuild-cli/src/cli/cache.rs(+cache_reclaim_tests.rs) — thereclaimsubcommand,the mid-build guard (
busy_reason), the default target (the pre-flight shortfall, measuredthrough
disk_preflight::measure— the same seam the build enforces) and the renderer.disk_cache/README.md— a gc-vs-reclaim table (trigger, target, order, mid-build).Tests
fbuild-packages-fetch(9, real files under a rootedtempdir_in): the order contract; stopbefore the next kind; stop inside a kind; install before archive; dry run reports the same
numbers and deletes nothing; pinned entries invisible; zero target is a no-op; an
unsatisfiable target evicts everything and reports the remaining bytes; a vanished path still
clears its row instead of failing.
fbuild-cli(9): mid-build refusal naming the operation; an idle daemon does not block; amissing or non-boolean status never blocks; ordered rendering with a satisfied verdict; the
SHORT verdict naming the daemon-owned zccache step; the dry-run label; the empty report;
human-size parsing.
Scope
This lands #1750 item 3 only. Items 1 (per-stage measured footprint) and the zccache budget
hookup stay open on the issue.