-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
Cache misses when using volatile keys in x_defs #2102
Comments
After examining the c example a little bit better, I realised that when Looking through the rules_go code, it seems like the dependency on the status files is only added when the
Where
This works for now, but it'd be great if |
Hmm, I tried your example. Bazel seems to relink both the Go and C binaries only after a
Given that the behavior is consistent between Starlark and native rules, I'm not sure there's anything to do here. In terms of rules_go implementation, the |
The clean was mostly to simulate the behavior experienced when filling the cache from one machine, and then consuming it from a different one. We have a sizable (thousands) number of linked binary/test targets that depend on a Reading a little more through the c rules, I think building with
Which currently isn't how rules_go behaves:
(unless resorting to the config_value as described above). What I'd like is that rules_go has the same If that isn't Starlark accessible, then this is more motivation to fix bazelbuild/bazel#1054. However, it seems like a little boilerplate with |
Ah, okay, I think I misunderstood earlier. I'm not sure if it occurred to me before that we could access the If you're open to sending a PR for this, I'd be happy to merge it. I think the right way to implement this is to add a |
I only recently learned about |
This adds support for rules_go to make stamping of workspace variables conditional to Bazel's --nostamp flag. Fixes #2102.
Just came across this issue. I do not get cache misses when the values in volatile status change, and values in stable status remain the same. This is because bazel makes a special case for volatile-status.txt and does not include it in the action digest. The trick is to ensure that your stable-status.txt does not change, even if you don't use any variables from stable-status.txt. We do this by using the value of an environment variable in the workspace status script. If that environment variable is set, we emit constant stable status variables, similar to the redacted mechanism you saw in C++ rules. The stamp flag also is not well documented, and C++ stamping can only be achieved if you were lucky enough to find examples, because the linkstamp attribute and what it does is undocumented. I think users managing stamping or no stamping through their workspace status script will be the way to go forward in general, because the redaction mechanism can not be generalized to arbitrary status variables. So far, they only work when your variables are from a limited set. Even if we start respecting the stamp configuration in rules_go, there are many other bazel rules that don't respect it, so you only get limited mileage out of it. But I do believe that it is a good idea to explicitly control stamping both at the rule level and globally. |
I'm running into unexpected caching behavior when using rules_go with stamping trough
x_defs
. Mainly based on experience with c binaries I'd expect to be able to get 100% cache hit, but the go binaries keep re-linking when using stamping with variables from the workspace status.What did you do?
Also available at https://gist.github.com/robbertvanginkel/925b10198e98010d0ca7ad722b5acbef
What did you expect to see?
Expected 100% cache hit when doing:
What did you see instead?
Only a partial cache hit, with recompilation of
When diffing the execution logs according to the process described at https://docs.bazel.build/versions/master/remote-execution-caching-debug.html#comparing-the-execution-logs, the root cause seems to be the
volatile-status.txt
file:This is unexpected, as the docs on volatile-status describe it should not trigger rebuilds.
For reference, the gist also contains a stamping example for a c binary, where this caching works as expected:
Which leads me to believe this is an issue with rules_go.
In searching around a little bit I've found bazelbuild/bazel#1054, which describes that starlark rules cannot access the workspace status. This seems to be fixed now though, however it seems like
--[no]stamp
cannot be interpreted/read from starlark, which might contribute to what I'm experiencing. (As what I'm seeing with go is very similar as with c when running with--stamp
).The text was updated successfully, but these errors were encountered: