Repository navigation
Conversation
…cache_dir SCons never evicts entries from build_cache_dir, so it grows without bound. Add optional age and size limits that remove least recently used entries, checked at most once a day when a build starts. Both are disabled by default. Only files inside the cache's bucket sub-folders are pruned; SCons' own root-level files (config, .sconsign*) are left alone. Invalid option values fail with a clear configuration error, and pruning is best-effort so it can never fail a build. Co-Authored-By: aphelps-claude-bot <277140888+aphelps-claude-bot@users.noreply.github.com>
This branch has not been deployed
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.
Closes Issue #5533
Summary
build_cache_dir(a SConsCacheDir) is never pruned, so it grows without bound. This adds two optional settings, both off by default (no behaviour change):build_cache_max_age: remove entries not used for N days (integer >= 1)build_cache_max_size: cap the cache size, e.g.500MB/10GB; least recently used entries go firstSCons updates a cache file's mtime on every hit (
SCons/CacheDir.py), so mtime is the last-used time. The prune:config,.sconsign*) are left aloneInvalid values (
build_cache_max_size = lots,build_cache_max_age = -1) fail with a clear config error. Size is enforced at build start, so a build can exceed the cap by what it adds.Real-world motivation: an ESP32/Arduino (WLED) project reached ~62 GB / 75k files in ~10 months, ~93% unused for over 45 days.
Test plan
pytest tests/misc tests/project: newtests/misc/test_build_cache_prune.pycovers age, size/LRU, both limits, root files and symlinks kept, dry run, throttle, future stamp, env vars, zero size, and invalid optionsblack/isort/pylintclean on changed filesPLATFORMIO_BUILD_CACHE_MAX_AGE=45: backdated entries removed, backdated rootconfigand.sconsign*survivedNot included: docs (separate
docssubmodule), apio system prune --build-cacheflag. Happy to add either if wanted.Developed with AI assistance (Claude Code) and reviewed by the author.