-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Builds invalidate cache from test runs and vice versa #13186
Comments
@sdtwigg Is this a duplicate of the work you are doing with trim test? |
Thanks for looking into this, @aiuto. It may be worth adding that this is a non-trivial issue for us. The usual developer workflow is to edit code, then run |
doesnt and can you share output or anything at least here? are you seeing sorry if these are obvious, unsure of your level of experience, but so far this is just sounding similar to different build/test configs maybe via bazelrc; trying the usual |
Thanks for the various pointers, @zachgrayio.
Not that I know, but will give it a try.
We're using the Bazel defaults, which I assume is a disk cache. I will share the output of Bazel once I have it.
Thanks, I'll give that a try. |
@smolkaj I think I found the issue:
Technically, this means that builds and tests are done with "different" options, so the cache is invalidated and a rebuild occurs. If we avoid specifying test and run opts, caching seems to work. |
Thanks @bocon13, great catch finding the root cause! To the Bazel authors: is it expected behavior that the cache gets discarded when the build options change? |
CC'ing @aranguyen , who's been looking recently into how Bazel interprets flag and Yes, it is expected that the cache is discarded when build options change. I'm not sure it's documented well, and I'm happy to support suggestions for better documentation. This is covered in bazel/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeBuildView.java Lines 334 to 339 in 3cd5f84
b/144932999 is a Google bug with no special secrets: it repeats this comment. I believe the issue was it's possible for different flag combos to produce the same action, so when Skyframe is asked to execute an action is can get confused about which variation to use. Conceptually, '-std=c++17' '-std=c++17' clearly shouldn't matter. Perhaps @aranguyen has some ideas about why that flag replicates and if there's any way to a better practical outcome. |
For the flag In this case, I would suggest to not have the test line in the bazelrc file if it is not different from the build line and let inheritance take care of it. @smolkaj, would this work? There is actually a similar github issue and both can probably be fixed by introducing deduplication for flags that allow multiple values. But this is low priority. |
Yes, thanks, this works for us, though I think it is quite brittle and it would be nice to fix the underlying issue. |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue is not stale. It would be nice to get a fix. |
IMO, what would be nice is a tool that users could run that would determine the diff in the env/flags that would allow us to determine why the cache is being invalidated. Or even just a way to determine "will the cache invalidate if I run it now" but don't actually run it. I often find the cache invalidates for seemingly no reason, and this is one of the biggest issues new users have when onboarding to my bazel-based project. |
Does |
That does help, thanks! |
FYI @susinmotion and @katre are looking at the Skyframe restrictions described at #13186 (comment) and seeing how much we can lift them. I'm hoping in the near-term we can avoid invalidating the exec-configured parts of the analysis cache (i.e. tools/compilers). They generally don't care about flags set at the command line. And they can be a surprisingly large part of the build graph. I'm not sure if that would kick in for |
Description of the problem / feature request:
Starting from an empty bazel cache, when we run
on our project, every single command seems to be rebuilding the cache; we observe very slow builds (~1h).
The following works:
Similarly for testing:
We have tried
--distinct_host_configuration=false
but it doesn't solve the issue.What operating system are you running Bazel on?
Ubuntu 20.04
What's the output of
bazel info release
?release 4.0.0
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?git@github.com:pins/pins-infra.git
80a739d0e2f15edbb185cc9061f66202a70fffd8
80a739d0e2f15edbb185cc9061f66202a70fffd8
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: