-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[FR] Add a way to disallow analysis cache discards #16804
Description
Description of the feature request:
Context: https://groups.google.com/g/bazel-discuss/c/hlJakHgizSo as well as discussions at BazelCon in the community day and rules authors SIG session.
I had agreement with @katre at BazelCon that it's a reasonable feature request to have a new flag that allows us to enforce that re-analysis isn't performed in a given build.
Of course, we should not fail the first time a target is analyzed, such as when a Bazel server is cold and doing the first build. I propose that the codepath which currently prints "INFO: Build option X has changed, discarding analysis cache" would simply fail the build under the new flag.
By using this new flag, Bazel users who intend to have fast, incremental rebuilds would be able to immediately discover that they've forgotten to pass the same Bazel options to every invocation of Bazel.
What underlying problem are you trying to solve with this feature?
This was one takeaway of the BazelCon community day session on slow builds due to re-analysis.
Currently it's easy to accidentally introduce a change that discards the analysis cache. Like non-determinism, this often creeps into a build silently, de-optimizing performance of CI pipelines in a way that maintainers only notice and repair after user complaints of "slow builds".
Flags like --run_under and --action_env are frequent causes as indicated below in the links.
Fixing the common pseudo-command in .bazelrc (#3054) would help with this problem but there are still cases where users pass flags on the command-line and did not mean to cause re-analysis.
Which operating system are you running Bazel on?
No response
What is the output of bazel info release?
No response
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
No response
Have you found anything relevant by searching the web?
- Changing starlark build setting always discards the analysis cache. #13591
- --run_under discards analysis cache #10782
Any other information, logs, or outputs that you want to share?
An alternative approach is to fundamentally address the expense of re-analysis, either by making it incremental, or as @aiuto proposed at BazelCon, eliminating configuration flags altogether. Those might be worth pursuing in the long term; this issue hopes to improve the situation for Bazel users immediately.
@JaredNeil indicated he would use this feature within his org.
Someone told me that @gregestren might be the reviewer of a PR to do this, so I'd like to confirm it would be accepted.
Note that there is a similar problem with Bazel server restarts with accidental changes to startup options, and also accidental external repository invalidations. I suspect it's better to address these problems separately but perhaps they should be considered in the same design effort.