Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cache): handle missing cache hits when chaining two run steps #19974

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bfredl
Copy link
Sponsor Contributor

@bfredl bfredl commented May 15, 2024

fixes #19817

This improves the efficiency of the cache when chaining muliple commands like

const step1 = b.addRunArtifact(tool_fast);
step1.addFileArg(b.path("src/input.c"));
const output1 = step1.addOutputFileArg("output1.h");

const step2 = b.addRunArtifact(tool_slow);
step2.addFileArg(output1);
const chained_output = step2.addOutputFileArg("output2.h");

assume that step2 takes much long time than step1
if we make a change to "src/input.c" which produces an identical "output1.h" as a previous input, one would expect step2 not to rerun as the cached output2.h only depends on the content of output1.h

However, this does not work yet as the hash of src/input.c leaks into the file name of the cached output1.h, which the second run step interprets as a different cache key. Erasing the "zig-build/o/{HASH}" part of the file name in the hash key fixes this.

@bfredl bfredl force-pushed the cache2 branch 4 times, most recently from da79a37 to b8081f8 Compare May 15, 2024 13:44
fixes ziglang#19817

This improves the efficiency of the cache when chaining muliple commands
like

    const step1 = b.addRunArtifact(tool_fast);
    step1.addFileArg(b.path("src/input.c"));
    const output1 = step1.addOutputFileArg("output1.h");

    const step2 = b.addRunArtifact(tool_slow);
    step2.addFileArg(output1);
    const chained_output = step2.addOutputFileArg("output2.h");

assume that step2 takes much long time than step1
if we make a change to "src/input.c" which produces an identical
"output1.h" as a previous input, one would expect step2 not to
rerun as the cached output2.h only depends on the content of output1.h

However, this does not work yet as the hash of src/input.c leaks into
the file name of the cached output1.h, which the second run step
interprets as a different cache key. Erasing the "zig-build/o/{HASH}"
part of the file name in the hash key fixes this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build.zig: issue with caching with chained build.step.Run steps
1 participant