std.Build.Cache: fix cache miss when metadata changes #37238

Merged
andrewrk merged 1 commit from cache-miss-regression into master 2026-10-15 08:17:30 +02:00
Owner

adds test for "changed metadata of input file but same digest causes hit"

closes #37200

adds test for "changed metadata of input file but same digest causes hit" closes #37200
std.Build.Cache: fix cache miss when metadata changes
Some checks failed
ci / x86_64-freebsd-release (pull_request) Successful in 38m49s
ci / x86_64-freebsd-debug (pull_request) Successful in 41m18s
ci / powerpc64le-linux-release (pull_request) Successful in 1h49m28s
ci / x86_64-openbsd-release (pull_request) Successful in 52m21s
ci / x86_64-openbsd-debug (pull_request) Successful in 1h3m8s
ci / aarch64-macos-release (pull_request) Successful in 1h8m28s
ci / x86_64-netbsd-release (pull_request) Successful in 52m20s
ci / x86_64-netbsd-debug (pull_request) Successful in 1h1m21s
ci / powerpc64le-linux-debug (pull_request) Successful in 3h3m40s
ci / aarch64-macos-debug (pull_request) Successful in 2h54m27s
ci / x86_64-linux-debug (pull_request) Successful in 1h45m25s
ci / x86_64-windows-release (pull_request) Successful in 1h7m0s
ci / x86_64-windows-debug (pull_request) Successful in 1h47m39s
ci / s390x-linux-debug (pull_request) Successful in 2h21m18s
ci / aarch64-freebsd-release (pull_request) Successful in 1h33m23s
ci / aarch64-freebsd-debug (pull_request) Successful in 2h5m1s
ci / s390x-linux-release (pull_request) Successful in 3h47m52s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 5h10m46s
ci / x86_64-linux-release (pull_request) Successful in 5h10m41s
ci / aarch64-linux-release (pull_request) Successful in 1h51m41s
ci / aarch64-linux-debug (pull_request) Successful in 2h13m3s
ci / aarch64-netbsd-debug (pull_request) Has been cancelled
ci / aarch64-netbsd-release (pull_request) Has been cancelled
ci / aarch64-openbsd-debug (pull_request) Has been cancelled
ci / aarch64-openbsd-release (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
3b3bb15c6a
adds test for "changed metadata of input file but same digest causes hit"

closes #37200
andrewrk merged commit 9343d0fe4b into master 2026-10-15 08:17:30 +02:00
andrewrk deleted branch cache-miss-regression 2026-10-15 08:17:32 +02:00
First-time contributor

This patch successfully fixed the problem where a direct dependency would continually be rebuilt. But it didnt fix the problem where a dependency of a dependency would continually be rebuilt. Maybe its user error, but I think I can reproduce it (I'm on macOS):

I can confirm that the 37238 patch fixes caching on direct dependencies in the current projects build.zig.zon, but not for the current projects child dependencies build.zig.zon.

I have made a package example-parent that imports example that imports zg

> git clone https://codeberg.org/loftafi/example-parent.git
> zig build
> zig build

Second zig build is properly cached.

Now, Increment the const a variable in src/main.zig:

> nvim src/main.zig
> zig build --summary  all
Build Summary: 16/16 steps succeeded
install success
└─ install t success
   └─ compile exe t debug native success 7s MaxRSS:360M
      ├─ options cached
      ├─ run exe canon (canon.zig) success 2s
      │  └─ compile exe canon debug native success 6s MaxRSS:346M
      ├─ run exe ccc (ccc.zig) success 457ms
      │  └─ compile exe ccc debug native success 6s MaxRSS:311M
      ├─ run exe compat (compat.zig) success 1s
      │  └─ compile exe compat debug native success 6s MaxRSS:332M
      ├─ run exe hangul (hangul.zig) success 1s
      │  └─ compile exe hangul debug native success 6s MaxRSS:316M
      ├─ run exe normp (normp.zig) success 866ms
      │  └─ compile exe normp debug native success 6s MaxRSS:332M
      └─ run exe quickcheck (quickcheck.zig) success 1s
         └─ compile exe quickcheck debug native success 6s MaxRSS:331M
This patch successfully fixed the problem where a direct dependency would continually be rebuilt. But it didnt fix the problem where a dependency of a dependency would continually be rebuilt. Maybe its user error, but I think I can reproduce it (I'm on macOS): I can confirm that the 37238 patch fixes caching on direct dependencies in the current projects build.zig.zon, but not for the current projects child dependencies build.zig.zon. I have made a package `example-parent` that imports `example` that imports `zg` ```shell > git clone https://codeberg.org/loftafi/example-parent.git > zig build > zig build ``` Second zig build is properly cached. Now, Increment the `const a` variable in `src/main.zig`: ``` > nvim src/main.zig > zig build --summary all Build Summary: 16/16 steps succeeded install success └─ install t success └─ compile exe t debug native success 7s MaxRSS:360M ├─ options cached ├─ run exe canon (canon.zig) success 2s │ └─ compile exe canon debug native success 6s MaxRSS:346M ├─ run exe ccc (ccc.zig) success 457ms │ └─ compile exe ccc debug native success 6s MaxRSS:311M ├─ run exe compat (compat.zig) success 1s │ └─ compile exe compat debug native success 6s MaxRSS:332M ├─ run exe hangul (hangul.zig) success 1s │ └─ compile exe hangul debug native success 6s MaxRSS:316M ├─ run exe normp (normp.zig) success 866ms │ └─ compile exe normp debug native success 6s MaxRSS:332M └─ run exe quickcheck (quickcheck.zig) success 1s └─ compile exe quickcheck debug native success 6s MaxRSS:331M ```
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ziglang/zig!37238
No description provided.