Repository navigation
CI: prune superseded ccache generations so the repo stays under the cache limit - #84
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 628dbc3846
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| freed=0; deleted=0 | ||
| while IFS=$'\t' read -r id created size key; do | ||
| [ -z "${id:-}" ] && continue | ||
| pre="$(printf '%s' "$key" | sed -E 's/-b[0-9]+-mix-[0-9a-f]+-?$//')" |
There was a problem hiding this comment.
Handle vanilla tags when deriving the cache prefix
When resolve produces a supported plain tag such as b1234 (the empty-PR-set path), saved keys end in -b1234-, but this substitution only strips -b1234-mix-<hash>-. Each vanilla generation therefore retains a unique pre, never exceeds KEEP, and is never pruned, allowing daily plain builds to reach the repository cache limit that this step is intended to prevent.
Useful? React with 👍 / 👎.
| # ── Keep the ccache budget inside the repo limit ── | ||
| # | ||
| # ccache entries are immutable, so every run writes a NEW cache per | ||
| # (cuda, os, profile) and finds the previous one by restore-keys prefix. | ||
| # restore-keys returns only the MOST RECENT match, so older generations can |
There was a problem hiding this comment.
Condense the non-ASCII cache commentary
This new 19-line comment block uses Unicode box-drawing characters and hard-wraps explanatory sentences across many lines. The repository's root instructions explicitly require ASCII-only text, concise comments, and avoiding fixed-column wrapping, so this should be reduced to a short ASCII comment while leaving detailed measurements outside the workflow.
AGENTS.md reference: AGENTS.md:L73-L77
Useful? React with 👍 / 👎.
| # | ||
| # Keeping 2 rather than 1: the second generation is the fallback when a job | ||
| # dies before saving, which is precisely the hole that forces a cold build. | ||
| - name: Prune superseded ccache generations |
There was a problem hiding this comment.
Run cache pruning after non-publishing builds
In the inspected unsloth-prebuilt.yml, this step is nested in reclaim, whose job-level condition at line 967 requires a successful publication. Failed builds still save their partial ccache generations through the reusable workflows' if: ${{ always() }} save steps, and publish:false dispatches also build and save caches, but neither path ever reaches this pruning step. A few consecutive failures or artifact-only test runs can therefore fill the cache budget before any successful release is available to clean it up, causing the eviction and cold-build behavior this change is meant to prevent.
Useful? React with 👍 / 👎.
Adds a second step to the
reclaimjob that deletes ccache generationsrestore-keyscan no longer select. This is a build-time change, not housekeeping.Why it affects compile time
ccache entries are immutable, so every run writes a new cache per
(cuda, os, profile)and finds the previous one byrestore-keysprefix.restore-keysreturns only the most recent match, so older generations can never be selected again.Measured on this repo before the change: 122 caches / 31.72 GiB, of which only 40 / 9.13 GiB were reachable. 71% of the budget was unreachable.
That matters because the repo cache limit is 50 GB across ~40 prefixes. Once the total reaches the limit GitHub evicts by its own LRU, which can take a live cache, and a partial cache is far worse than a cold one.
Measured locally over 513 real translation units:
A preprocessed-dominant split is the fingerprint of a truncated cache: manifests are evicted, some objects survive, and lookups fall through to the slow path. CI showed exactly that (3 direct / 52 preprocessed) while the cap was 500 MB, and that run took 204 minutes against 54 for the same job with a healthy cache.
Projection now that 4a03725 has stopped the truncation and caches can reach full size:
So without pruning the repo grows into GitHub-side LRU eviction, which reintroduces the truncation that cost those 150 minutes.
What it does
Groups caches by their
restore-keysprefix (the key minus its-<tag>-suffix), sorts newest first, and deletes everything pastKEEP: 2. Keeping 2 rather than 1 because the second generation is the fallback when a job dies before saving, precisely the hole that forces a cold build.It also emits a job summary and raises a
::warning::above 40 GiB, so the squeeze is visible before it bites.Safety
reclaimjob, which already holdsactions: writeand only runs when this run published (needs.assemble.outputs.published == true).continue-on-error: true, so cache housekeeping can never fail a published release.Testing
The step was extracted from the YAML and run against the real 122-cache list from this repo with a stubbed
gh: it selected exactly 60 caches / 16 GiB, identical to the manual prune performed today, and left the newest 2 per prefix.bash -nclean, all workflows parse.Follow-up, not in this PR
Install CUDA toolkitcosts 7.1-8.8 min on every cuda12 leg via Jimver, against 0.8-1.1 min on the cuda13 legs which use the NVIDIA redist method already present in this workflow. Moving cuda12 to redist looks worth about 7 min x 4 jobs per run, but it needs the 12.8 component list pinned and tested before it goes near the release path.