Repository navigation
CI: zig and zig-windows keep main's build cache, and the quick checks run first - #2140
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/ci-build-cache
branch
3 times, most recently
from
November 4, 2026 20:29
33eb8ed to
9295235
Compare
ashhart
marked this pull request as draft
November 4, 2026 21:46
4 tasks done
ashhart
force-pushed
the
lead/ci-build-cache
branch
from
November 5, 2026 09:22
9295235 to
0f7eec1
Compare
ashhart
marked this pull request as ready for review
November 5, 2026 09:23
This was referenced Nov 5, 2026
Closed
ashhart
added a commit
that referenced
this pull request
Nov 5, 2026
ashhart
force-pushed
the
lead/ci-build-cache
branch
from
November 5, 2026 11:05
0f7eec1 to
dfd8699
Compare
… run first setup-zig empties its cache past 2 GiB and saves the empty folder. Both jobs have outgrown that (Linux 5.9 GB, Windows 3.7 GB), so every run restores nothing and rebuilds from scratch: zig p50 17.8 minutes, zig-windows 24.2. Main now saves the cache after each run, and pull requests restore main's newest and save nothing. A pull request's run tests its merge with the latest main, so it compiles little beyond its own diff. Nearly every test imports core, platform, hip and zig/src's top-level files, so a change to them recompiles nearly everything. The key carries their hash, and main starts from nothing when it changes. That keeps one build in the cache: adding to the last one doubled it (0.85 to 1.5 GB on one core edit). A compile's manifest names builtin.zig files in zig's global cache, and a fresh runner has none, so restoring .zig-cache alone missed nearly every compile. The global cache now sits inside .zig-cache and is kept with it. The cache saves compiles only. -Drerun-tests makes every check run again, as it does today, so a test that reads a fixture at run time can't pass on an old result. Generators keep their cache, since compiles read what they write. The shared CUDA copies check and the lean check take about three seconds and were three of the last four red mains. They now run before the builds.
ashhart
force-pushed
the
lead/ci-build-cache
branch
from
November 5, 2026 11:10
dfd8699 to
84e44eb
Compare
This was referenced Nov 5, 2026
2 tasks
ashhart
added a commit
that referenced
this pull request
Nov 5, 2026
…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.
ashhart
added a commit
that referenced
this pull request
Nov 5, 2026
…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.
ashhart
added a commit
that referenced
this pull request
Nov 5, 2026
…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.
ashhart
added a commit
that referenced
this pull request
Nov 5, 2026
…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.
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.
zigandzig-windowsrebuild from scratch on every run.mlugg/setup-zigempties its cache folder past 2 GiB and saves the empty folder, and both jobs have outgrown that. From main's green run:Cache directory reached 5931725721 bytes, exceeding limit of 2147483648 bytes; clearing cache.zig/src/core,zig/src/platform,zig/src/hipandzig/src's top-level files. Nearly every test imports them (96%, 87%, 76% and 88% of 126 test builds sampled from our gate cache), so a change there recompiles nearly everything, and main then starts from nothing. Adding to the old cache instead took it from about 0.85 to 1.5 GB on onecoreedit, which would have filled the budget within a day or two.-Drerun-testsreruns all checks, whatever the cache holds, and only compiles are reused. A test that reads a fixture at run time can't pass on an old result. Generators keep their cache.The other jobs keep setup-zig's own cache; this PR doesn't touch them.
Measurements
Job time in minutes:
zigzig-windowsThe warm numbers I gave here earlier were wrong, so I've removed them, and the cause I gave for that was wrong too. I said the runs had missed zig's global cache, and added
ZIG_GLOBAL_CACHE_DIRto fix it. That setting does nothing on CI:setup-zigalready puts the global cache inside.zig-cacheand overrides it. It will be removed. The misses themselves are real: on one fresh runner, 224 of 240 compiles and all 235 test runs repeated. A different cause is being tested on #2172 and tracked on #2242. This PR claims no speedup until that's settled.Where the test time goes is now measured in #2172.
zig/qwen4_family.zigalone takes over 6 minutes on Linux and over 3 on Windows. That's the next thing to fix.Also seen while testing, and not from this PR: two
zig-windowsruns on 4 Nov hit the 60-minute limit with no output after 28 minutes, while others on the same base passed. That hang is still unexplained.Test plan
-Drerun-testsreruns a test the cache would have skipped (run test cachedwithout it, a real run with it)build_options_testpasses with the new option