Description
Description of the feature request:
Let users put a size ceiling on the repo contents cache. As far as I can tell, today, the only eviction signal is age (--repo_contents_cache_gc_max_age), so on busy workspaces the cache grows without bound until the age window kicks in. A companion size-based knob would let users say "keep this cache under 20 GB" and have Bazel evict the oldest entries to honour it: matching the pair of knobs the disk cache already exposes (added in #23833).
Which category does this issue belong to?
Performance
What underlying problem are you trying to solve with this feature?
The repo contents cache (introduced via #12227, made GC-aware in #26080) only supports age-based eviction today. A few workflow patterns combine to make the cache grow faster than the age window evicts:
- Multiple workspaces /
git worktreecheckouts sharing one--repo_contents_cache. Every workspace adds entries; none individually feels the cost. MODULE.bazelchurn: version bumps, added or removed modules shifts predeclared-input-hashes. Old entries are no longer referenced but still don't age out for 14 days.- Every touch resets an entry's age clock, so the cache grows with the working-set size of all dependency churn over the age window, not with what's in use today.
Concrete: the contents/ directory under one of my caches grew to ~91 GB within a single 14-day window before disk pressure forced a manual rm -rf (on a dev laptop). A user wanting to keep it under (say) 20 GB has no tool for it short of deleting the directory by hand.
The disk cache already has both knobs, this asks for parity.
Which operating system are you running Bazel on?
macOS 26.4.1
What is the output of bazel info release?
release 8.7.0 (currently upgrading to 9)
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
cc:
- @Wyverald (PR #26080, original repo contents cache GC)
- @tjgq (PR #23833, disk cache GC pattern this mirrors)