-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
zig build: add env_map entries to hash for Step.Run #20874
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
Conversation
bac8640
to
44d1544
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still wrong... please use std.mem.sortUnstable
Done. |
39d727b
to
5b22d5b
Compare
5b22d5b
to
4d0635b
Compare
This change fixes false-positive cache hits for run steps that get run with different sets of environment variables due the the environment map being excluded from the cache hash.
4d0635b
to
acdb567
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me.
@squeek502 any thoughts on the Windows thing?
For Windows, I believe you'd want to do something like: Before the
(but it seems like a quite rare situation where this normalization would matter if I'm thinking about it right) |
Yeah, I don't think this necessarily needs to block the PR considering how much of an edge case it is. IIUC, it seems like the worst case scenario is that two otherwise identical commands using e.g. I think it'd be fine to merge this as-is and leave the Windows fix as follow-up work, but I'll let @dweiller decide if he feels like doing it in this PR. |
Yes, that would be what happens without normalisation.
I'd rather leave normalisation on Windows to follow-up work if possible as I'm not familiar with Windows path name details (and wouldn't be able to test it locally). While I don't think it's ideal to not have normalisation I expect it be be very rare someone would hit it, and it is at least possible to work around in |
Follow-up filed at #23366. |
This change fixes false-positive cache hits for run steps that get run with different sets of environment variables due the the environment map being excluded from the cache hash.
I assume the exclusion of the
env_map
field from the cache hash of aStep.Run
was an oversight as it is important for use cases where environment variables are used to control program behaviour (I encountered this issue when using AFLPlusPlus where environment variables are used to enable different instrumentation options). If it was intentional I can open an issue to discuss changing this behaviour.The implementation in this PR sorts the environment variables by the variable name to ensure that any reordering does not cause a cache miss. I have not implemented special-case logic for windows to normalise environment variable name case before hashing, so you can get cache misses if different codes paths in
build.zig
add the same environment variable (and value) but use different casing for the variable name.