Repository navigation
CI: main's build cache fits every runner, and release-paths and macOS use it too - #2252
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/ci-cache-compile-jobs
branch
from
November 5, 2026 17:40
0dca2c7 to
8cc4afd
Compare
…ts every runner A compile's cache key carries its CPU, and host code compiles for the runner's own. GitHub's runners differ, so a restored cache missed nearly every compile unless the runner drew the CPU main's last save ran on. In one probe on a small target, with four different CPUs among the Linux runners, 1 of 4 restored jobs hit on Linux and 0 of 4 on Windows. With -Dfixed-cpu, which compiles host code for x86_64_v3, all 8 hit, in 2-7 s instead of 108-263 s. This removes the ZIG_GLOBAL_CACHE_DIR setting #2140 added. It does nothing on CI: setup-zig already puts the global cache inside .zig-cache and overrides it, so the reason that commit gave for the misses was wrong. The key moves to v3, so main starts from an empty cache rather than keeping builds for each runner's own CPU alongside the new one.
These two jobs only compile, so a warm cache saves most of their time. Pull requests saved their own caches, which no other pull request can read and which filled the budget, and setup-zig emptied any past 2 GiB. macOS waited longest for a runner: 10 minutes at the median and 39 at p90, then 13 to run (5 Nov, 63 pull request runs). They now do as zig and zig-windows do: main saves, and a pull request restores main's newest and saves nothing.
ashhart
force-pushed
the
lead/ci-cache-compile-jobs
branch
from
November 5, 2026 18:23
8cc4afd to
d85258f
Compare
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.
A kept build cache only helps if it fits the runner that restores it, and on GitHub's x86 runners it mostly didn't. This makes main's cache fit every runner, and moves
release-pathsandzig-macos-dev-toolsonto the same cache.Why a restored cache missed
A compile's cache key carries its CPU, and host code compiles for the runner's own CPU. GitHub's runners differ: in these runs Linux drew EPYC 9V45, 9V74 and 7763 and Xeon 8370C and 8573C, and Windows drew Xeon 8370C and EPYC 7763, 9V45 and 9V74. So a restored cache hit only when a runner drew the CPU main's last save ran on.
In a probe on a small target (run 42027275042), 1 of 4 restored Linux jobs hit and 0 of 4 on Windows. With
-Dfixed-cpu, which compiles host code forx86_64_v3, all 8 hit, in 2-7 s instead of 108-263 s.The suite passes on
x86_64_v3at full size (run 42038532226): Linux 7,127 passed and 59 skipped in 701 s cold, Windows 6,576 passed and 141 skipped in 1,475 s cold. A Windows job that restored that cache on a different CPU took 329 s, with every test run again. That is one run of each, and the restoring CPU was newer, so it isn't an exact ratio.What changes
-Dfixed-cpuon everyzig buildline inzig,zig-windowsandrelease-paths. It only sets the host CPU on x86_64, and only when asked, so local builds keep their native CPU.zig-macos-dev-toolsruns on arm64 and doesn't need it.release-pathsandzig-macos-dev-toolsrestore main's newest cache and save nothing on a pull request, aszigandzig-windowsdo. Each pull request run saved about 1 GB of its own cache (about 520 MB for macOS, 475 MB forrelease-paths) that no other pull request could read. On 5 Nov the repository held 11.9 GB against GitHub's 10 GB limit, and a 936 MB entry was evicted within about an hour.v3, so main starts from an empty cache rather than keeping builds for each CPU alongside the new one.ZIG_GLOBAL_CACHE_DIRlines CI: zig and zig-windows keep main's build cache, and the quick checks run first #2140 added are gone. They did nothing, and the reason CI: zig and zig-windows keep main's build cache, and the quick checks run first #2140's commit message and this PR's first version gave for the misses was wrong:setup-zigalready puts the global cache inside.zig-cacheand overrides that setting from its step on.What it doesn't do
-Drerun-testsstays until the next PR, which lets a pull request reuse main's passes.zig/src/core,platform,hiporzig/src's top-level files still recompiles nearly everything.release-pathsand macOS have no warm number in this form yet, so they claim the budget saving and no particular speedup.Test plan
v3key yetcached