Repository navigation
fix(pruner): evict whole bun packages instead of single files - #27
Merged
Merged
Conversation
lru_cap evicted single files across /root/.bun by atime. bun reuses install/cache/<pkg>@<ver>@@@1/ as complete whenever it exists, so an evicted file vanished from every later node_modules. 0-byte files went first (copying never reads them, so their atime never moves): next@16.3.8 lost dist/compiled/server-only/empty.js and every Next build on the cx43 runners failed with "Can't resolve 'server-only'". It could also evict bin/bun. lru_cap_bun drops whole package folders (scoped ones included), oldest package.json atime first, along with their <pkg>/<ver> symlinks, until the volume fits the cap; it never touches bin/ or the @t@ piles and clears temp leftovers older than an hour. hk stays on lru_cap: its entries are independent whole files (config json, pkl zips). Adds tests/pruner-bun.sh (fails 16 checks on the old code) and a shellcheck + tests job to the PR build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
prune_cachesranlru_cap "$runner/bun", which LRU-evicts single files by atime across the whole/root/.bunvolume. bun treatsinstall/cache/<pkg>@<ver>@@@1/as complete whenever the folder exists, so an evicted file silently goes missing from every laternode_modules.0-byte files go first, because copying them never reads them and their atime never moves. On the
hetzner-cx43-runner-*runners (cap 8 GiB, pruner loggedevicting least recently used files from /caches/3/bunon 10-16 and 10-17),next@16.3.8lostdist/compiled/server-only/empty.js. After that, every Next build failed withModule not found: Can't resolve 'server-only'(dodi-smart/nis-suite#142). The same eviction can also delete/root/.bun/bin/bun.Fix
lru_cap_bun, modelled onlru_cap_mise_installs. It evicts whole package folders, oldestpackage.jsonatime first (dir mtime when there is nopackage.json), until the whole volume fits under the cap (excess_byteson the volume). This covers bothcache/<pkg>@<ver>@@@1and scopedcache/@scope/<pkg>@<ver>@@@1. It also removes the matchingcache/<pkg>/<ver>@@@1symlink and any empty name/scope dirs.bin/or the@t@manifest piles. It clears*.tmp/*.partleftovers andcache/.tmp/*entries older than 60 min; the age guard keeps it away from installs that are still running.prune_cachesnow callslru_cap_bun "$runner/bun".lru_cap: its volume holdsconfigs/<hash>.jsonandpklr/packages/<hash>.{zip,url}. Each of these is an independent whole file that gets regenerated or re-downloaded when it is missing. There are no per-tool/version trees, and the volume is ~1 MB, far below the cap.pruner.shreturns early when it is sourced, so tests can call its functions.Test
tests/pruner-bun.sh(plain bash, needs GNU find/stat/du) builds a fake bun volume. It holds packages with 0-byte files that have very old atimes, a scoped package, the version symlinks,@t@piles,bin/bun/bunx, and stale and live temp entries. It then runsprune_cacheswith a cap that requires dropping exactly the three oldest packages. A newscriptsjob in the PR build runs shellcheck andtests/*.sh, and thegatejob now requires it.Against
main'spruner.sh, the same test fails 16 checks, among themnext lost server-only/empty.jsandbin/bun removed.shellcheck -x pruner.sh tests/pruner-bun.shis clean.Separately,
CACHE_CAP_BYTESon the cx43 host was raised from 8 GiB to 12 GiB (62 GB free on that disk; done outside this PR).🤖 Generated with Claude Code