Repository navigation
ci: zig-restat, taking a restored zig cache's new inodes into its manifests - #2609
Merged
Merged
Conversation
…ts run-local's copied cache
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.
zig 0.17 (pinned in #2600) recompiles every C file after CI restores its build cache: a boot of ~100 s where 0.16 took 8 s.
Cause: zig's own cache check.
std/Build/Cache.zig'scheckInputPathre-hashes a direct input whose stat moved. It then compares the hash against a digestaddInputPathnever computes, which starts as zeros, instead of the digest the manifest holds. The compiler adds every C source that way (src/Compilation.zig:1323), and a restore from a tarball gives every file a new inode, so every C compile misses. This is in 0.17.0 and in upstream master.This PR adds
ci/cosmic_ci/zig_restat.tl. The driver's boot runs it before its first build, wherever the project cache was restored (CI's seed) or copied (run-local). For each file a manifest lists:Trusting a restored file by size and mtime adds no trust: zig never reads a restored output's bytes at all. The run logs one line, e.g.
zig-restat: 295557 files listed: 68852 given their new inode, 53 re-hashed and taken, 32 left; 1815 manifests rewritten. There's also adriver.tl zig-restatverb.zig_prune.tlnow shares aZigPrune.recordsreader and exportsZigPrune.key, and its tests are unchanged. Theci.ymlTODO about this cost becomes a plain comment, and the TODO moves to the workaround itself.Verification
tar --posixround trip of real 0.17 caches, at the same path, thenbin/zig build boot:ci/cosmic_ci/zig_restat_test.tlcovers:zig envparsingcosmic_ci(198 tests, unsandboxed as CI runs them),ci/'sfix --check,fix --check .,build/workflows_test.tlandci/run-localall pass.Review
A separate agent checked this against zig 0.17's
Cache.zigand the real caches. It found nothing blocking:Its nits:
bin/zig envnow runs only when there is a cache to restat, in the tree, with the driver's cache settings.run-local's copied cache is restatted too.queue-seed.sh, plaintar -cf) keeps whole-second mtimes, so a seeded entry goes through the re-hash path instead: about 15–20 s, still correct. The fix is a format flag that differs between GNU tar, the macOS legs' BSD tar, and BusyBox in the Alpine container, so I didn't touch it.TODOs
ci/cosmic_ci/zig_restat.tl:25. Remove this module and its call inbootonce the pinned zig'scheckInputPathcompares against the manifest's digest. Not yet reported upstream; a reproducer is drafted..github/workflows/ci.ymlTODO about the restored cache recompiling. It's now a comment pointing here; the TODO itself moved to the line above.ci/cosmic_ci/zig_prune.tl:107(from hash: Hash.siphash, SipHash in C with any round count and a 64- or 128-bit tag #2605). Restat's hashing goes throughZigPrune.siphash128, so it switches to the nativeHash.siphashwhen the driver pin moves. That's a follow-up once main'snext-prerelease carries hash: Hash.siphash, SipHash in C with any round count and a 64- or 128-bit tag #2605.🤖 Generated with Claude Code
https://claude.ai/code/session_01CA9Ta9WPb5KjCoDaYyN7qE
Generated by Claude Code