notes

The Actions cache budget, 2026-10-07 (provisional name)

Measured 2026-10-07 (UTC), read-only, at base 1f5be6843, by lane/actions-cache-budget. Pull request #1810 (measure Kani's install instead of caching it) found the repository's Actions caches at 10.8 GB in 461 entries, over GitHub's 10 GB limit, and rust-cache logging No cache found. calef approved measuring it the same day. The question: which caches earn their bytes, and what layout fits under 10 GB with room to spare. The scripts are in actions-cache-budget-2026-10-07/, with the commands in its README.

Result.

This pull request stops merge groups saving rust-cache entries, with a script/lint check, and on calef's rulings drops rust-cache from 14 of the 17 jobs (section 5).

1. What the cache holds

gh api repos/nifeos/nife/actions/caches --paginate, 2026-10-07 about 14:50 UTC. Usage then read 10,733,031,662 bytes in 455 entries; the paginated list returned 469 distinct entries, 10.99 GB, as entries came and went during the read.

Ref Entries GB Never restored
pull request (refs/pull/N/merge) 301 6.78 210
merge group (gh-readonly-queue/main/...) 163 3.78 163
main 5 0.43 1

"Never restored" means last_accessed_at within ten minutes of created_at. GitHub updates the access time on a restore, so this is a lower bound on waste, not an exact count.

By producer, the rust-cache entries split evenly across 17 jobs in ci.yml and verify.yml, from clippy (39 entries, 1.35 GB, 35 MB each) down to prove-kernel-riscv64 (18, 0.21 GB). No one job is the problem; the count of jobs times the count of refs is. Each job saves its own entry (add-job-id-key), on every pull request and every merge group.

Why main has none. A′ (notes/merge-queue.md, 2026-09-24) skips the heavy jobs on a push to main because the merge group already ran them. That note predicted this: "A′ lets main's Actions caches go stale ... Nobody has measured it yet." It is now measured, and it is worse than stale. The rust-cache entries main once had have been evicted, and nothing writes new ones.

2. Hit rates and what a hit buys

Method. The last 40 runs each of ci.yml and verify.yml, the 34 that concluded success or failure, 618 jobs, 354 of them with a rust-cache step. Each job's log was read for the step's start, its Cache Configuration line (key computed), the restore's outcome (No cache found, Cache hit for, Cache hit for restore-key), the next step's start, and the post-job save.

Event Jobs Exact hit Restore-key hit Miss Key computation (median) Restore (median) Saves
pull_request 243 58 38 147 17.6 s 0.3 s 185
merge_group 111 0 0 111 17.1 s 0.2 s 111

Saves took a median 2 s, and up to 6 s for clippy. Across the 354 jobs, rust-cache spent 102 runner minutes computing keys, 12 saving and 3 restoring, about 3.5 minutes a run.

What a hit buys, as median job wall time on a hit against a miss:

Job Hits Misses Hit Miss Gain
falsify-shard 11 9 16.7 min 20.4 min 3.7
prove 10 19 14.9 17.6 2.7
clippy 4 19 4.0 6.0 2.0
fuzz 4 16 11.6 12.0 0.4
the other 12 2 to 11 8 to 29 -2.3 to 0.2

The rest are noise around zero (cpu-matrix-shard's -2.3 is a slower hit). The reason is in what rust-cache keeps. It caches target/ after removing the workspace's own crates, so a hit saves compiling registry dependencies only. This tree's heavy jobs spend their time building its own crates for bare-metal targets and running QEMU, which no cache entry holds.

Where the 17 s goes. rust-cache 2 (commit 6323deb, src/config.ts and src/workspace.ts) runs rustc -vV once per installed toolchain and cargo metadata --all-features per workspace before restoring, and hashes every Cargo.toml it finds. In the sampled clippy job the pinned nightly was already installed when the step ended, with no install output in the log, so some jobs pay rustup's install of nightly-2026-10-06 inside this step. In the 140 jobs where that install shows later in the log, the step still took a median 15 s. How much of the 17 s cargo would pay later anyway (the registry index fetch cargo metadata performs) was not separated; it needs one job run with and without the step.

3. Prior art, read

4. What changed in this pull request

Every Swatinem/rust-cache step in ci.yml and verify.yml (18 at first) carries save-if: ${{ github.event_name != 'merge_group' }}. A merge group still restores (from main, when main has something), so nothing that hits today stops hitting. The measurement is at the first step in ci.yml.

helpers/cache_save_scope.py, run by script/lint, refuses a rust-cache step without that scope in any workflow whose on: lists merge_group. Watched failing on the 18 steps at base 1f5be6843.

Expected effect: about 39% fewer bytes written, so the 12-hour horizon should stretch toward 20 hours at the same pull request traffic. The cache will still fill to the limit, as an LRU cache does. Being at the limit is not the harm; evicting entries before their second use is.

5. One job without rust-cache, then the drop

stack-frame-check ran without the step on this branch (job 112877874401, run 37646272872): 115.7 s, against a median 112.8 s over the 20 runs with it (range 79.9 to 120.0). The step's 19.6 s did not vanish. The first script/ci-build step took 44.1 s against a median 23.0, because it now paid for what rust-cache's cargo metadata and rustc -vV had triggered. So dropping the step costs no time and saves none on this job; it saves the bytes and one moving part. One sample, inside the range.

Correction: 14 jobs, not 13. The fork and the first draft of this note said 13 jobs gained under half a minute. fuzz gained 0.4 minutes, which is also under it, so the count is 14 of 17.

Dropped, on calef's ruling: bench, boot-check, coverage, cpu-matrix-shard, fuzz, image-permissions, interleavings, stack-frame-check, supply-chain, swish-check, swish-check-x86_64 and test in ci.yml, prove-kernel-aarch64 and prove-kernel-riscv64 in verify.yml. watchdog also lost its step; it ran in none of the 34 sampled runs, so it is unmeasured, and it is neither of the three kept jobs. Kept: clippy, prove and falsify-shard, each saving only outside merge groups.

Caveats, together

Forks, and calef's rulings

calef ruled all three on 2026-10-07 (UTC), on #1814.

(a) Where should a pull request's first run get a warm cache?

main has none, so every first run misses. The options were:

  1. Nothing more.
  2. bevy's layout: a workflow on push to main saves, and every job restores only. It costs a build per merge.
  3. Drop rust-cache from the jobs where a hit gained under half a minute. Keep it on clippy, prove and falsify-shard, with shared-key where jobs build the same graph.

Ruled: option 3, measured on one job first, and without shared-key. The three kept jobs build different graphs (clippy lints the host and kernel crates on x64, prove and falsify-shard run Kani, falsify-shard on arm64), so one shared entry would be overwritten by each in turn and serve none. Section 5 records the measurement and the drop.

(b) sccache or another backend?

Ruled: no remote compile cache. rust-lang/rust's model needs a bucket, credentials and a new dependency, and what it would cache is dependency compiles, which are not where these jobs spend their time. Revisit if job timings show dependency compiles taking real time.

(c) Something that shows this before a lane trips over it

Ruled: yes. The proposal is now milestone 822 (the Actions cache horizon is charted), design/roadmap/0822-the-actions-cache-horizon-is-charted.md. Its number is provisional until the queue lands it. It samples bytes against 10 GB and the eviction horizon daily and charts them in notes/project-metrics.md. The horizon is the number that matters; a full cache with a week's horizon is healthy.