Repository navigation
Conversation
mlugg/setup-zig@v2 restores its cache into $GITHUB_WORKSPACE/.zig-cache.
In all eight Zig jobs of brain-ci.yml it ran before actions/checkout,
which finds no clone in the workspace and empties it ("Deleting the
contents of '/home/runner/work/trinity-fpga/trinity-fpga'"). Every
restored cache was deleted before a build step used it.
Measured with `speed zigcache` over the last 25 completed brain-ci runs:
238 restores, 0 used. 237 were hits that checkout then deleted; 1 was a
miss. Each job still paid about 1-1.8 s to restore and 1-2.4 s to save
26-71 MB. On 2026-10-05 those saves were 157 of the 179 Actions cache
entries, 7.95 GB of 11.04 GB, where they evict the chipdb (#844).
Check out first, in every Zig job. No step, condition or input changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cache mlugg/setup-zig restores into $GITHUB_WORKSPACE/.zig-cache, and an actions/checkout of the workspace after it deletes the restored cache. This is how brain-ci lost every hit (238 of 238 in 25 runs), and nothing stops the old order from coming back. tools/check_setup_zig_order.py reads every workflow with PyYAML and exits 1 for a caching setup-zig step followed by a checkout of the workspace. A checkout into a subdirectory and `use-cache: false` both pass. It exits 2, not 0, when no job uses setup-zig or a workflow does not parse. tools/test_check_setup_zig_order.py plants 17 cases. Four mutants of the checker are each caught. On this branch: 122 workflows, 16 setup-zig jobs, 0 findings. On main's brain-ci.yml: 8 of 8 jobs reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The five brain-unit matrix legs got one setup-zig key, so the first leg
to finish saved and the other four were refused ("Unable to reserve
cache"): 88 of 110 saves in 25 runs. Every leg then restored that one
region's build and compiled its own test binary from nothing. setup-zig
documents `cache-key` for exactly this: include the matrix variables.
Stacked on #890, which makes the restored cache survive checkout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
X Brain Health CheckScore: 100.0/100 X Brain is above merge threshold |
🧪 Brain Stress Test ResultsScore: not measured (no stress test prints a Score: line) X Stress test passed |
6c8cc6d to
277e06b
Compare
Summary by t27-beesThis PR fixes two CI cache problems: (1) Worth a look
Read: 4 files, +308 -40, the whole diff. Head |
Part of #844 and #851 (W4b). Stacked on #890, so merge #890 first. Until then this diff also shows #890's two commits.
What
Sets
cache-key: ${{ matrix.region }}on themlugg/setup-zigstep of brain-ci'sbrain-unitjob. That job has five matrix legs. Nothing else changes.Why
setup-zig's key is
setup-zig-cache-v2-<job id>-<tarball>-<cache-key>-<run id>-<attempt>. Withcache-keyempty, all five legs ofbrain-unitget the same key. The first leg to finish saves, and the other four fail with "Unable to reserve cache". Over the last 25 runs on main, 88 of 110 saves were refused.In the next run every leg restores that one region's build, which is useless for the other four. Each leg tests a different region, so they compile their own test binary from nothing. setup-zig's
action.ymldocumentscache-keyfor exactly this case: "When using a matrix strategy, this should include the matrix variables to ensure all jobs are cached."Measured
I measured this with two dispatches of this branch at 9256591. That commit has the same
brain-ci.ymlas this head, which has since been rebased onto #890's new head. The figures come fromspeed zigcache --workflow brain-ci.yml --branch ci/brain-unit-cache-key --runs 2.…-0.16.0-hslm-37251590313-1..zig-cacheGBTwo of the five legs reused their entry, since their directory did not grow. The other three each rebuilt about 60 MB.
#844 found that a warm entry is reused only on the runner CPU model that saved it, so a 2-of-5 reuse rate is what that finding predicts. That link is an inference, though. This branch has no CPU probe step, so I don't know which CPU each leg ran on. The CPU part is pinned with
-Dcpu, which is measured in #844 and is a separate change for the owner to decide.What this PR guarantees is that each leg restores its own region's build. Whether that build can be reused then depends only on the CPU model, and no longer on which leg happened to save first.
Cost
Each run now stores five entries instead of one. Gen 2 restored entries of 26.2–26.8 MB, so this is about 132 MB per run against about 26 MB. They count toward the same 10 GB Actions cache limit as the chipdb entries. #853 prunes entries that nothing can restore.
Not measured
🤖 Generated with Claude Code