-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Duplicate builds due to transitions of targets that don't depend on build settings #13281
Comments
Exists in 4.1.0 |
I switched this to a What you're describing falls into some form of "trimming". If you're specifically concerned about actions running on remote executors, the work I'm doing at #6526 may address that and I'd encourage you to follow that issue. |
@gregestren Thank you for the update! Makes sense, I understand the reasoning.
Thanks for the reference. In this issue here I'm not concerned about remote execution but about the configuration aspect.
|
What's your primary concern about this behavior? I.e. build slowness? Memory usage? The basic challenge is knowing where in the dep graph the dependency on the flag actually ends. And how to encode that in a way that remains correct (don't remove the flag prematurely), performance, and not burdensome for the user (i.e. manually tagging every edge on the graph that should keep the flag, which doesn't scale well. Are there any alternative configurations where the part of the graph that needs the flag is its own distinct subgraph? i.e. isolate the part of the graph to propagate the flag by flag structure? I think that opens up more options. As an aside, I'm surprised to read about collision at https://github.com/aherrmann/bazel-transitions-demo#gotchas. I didn't look super-thoroughly, but that should be hard to actually do in practice (i.e. collisions shouldn't really happen unless someone is egregiously abusing a rule). Is that specific to |
Build slowness induced by unnecessary rebuilds of the same target. E.g. external dependencies such as
I'm not sure I understand what this means. Do you have an example in mind of what this would look like?
The issue occurs when one combines the same target under different configurations in rules or other mechanisms that operate on paths relative to the package or
(i.e. there is a collision on both This seems to be sensitive to the order in which dependencies are declared: If I swap the deps sh_binary(
name = "runfiles",
srcs = ["runfiles.sh"],
- data = ["bin-ce", "bin-ee"],
+ data = ["bin-ee", "bin-ce"],
deps = ["@bazel_tools//tools/bash/runfiles"],
) then the output becomes
I guess whether this counts as egregious abuse depends on the use-case. We abandoned the transitions based approach because of this issue, so I can't provide a production example. But the following made-up example doesn't seem too absurd: Following the community vs. enterprise version example above, we may want to write an integration test that both enterprise and community clients can participate in the same network. In that case both versions would be runfile dependencies of the integration test target. At that point we need to be careful not to trigger the issue above. |
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 ( |
@bazelbuild/triage not stale |
Description of the problem:
Targets that don't depend on a user defined build setting are effectively duplicated when depended upon by targets that depend on a build setting and use a configuration transition.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Check out aherrmann/bazel-configuration-rebuild@2be2a62
Follow the steps in the README:
The target
//:cat
is independent of the user defined build flag//:flag
.The target
//:flag_cat
on the other hand depends on the value of the flag andon
//:cat
as well.The target
//:cat
is only built once, and cached under the same action cachekey, if the configuration is set via command-line flag.
The targets
//:transition_default
and//:transition_different
use aconfiguration transition to set the value of the build setting
//:flag
to"default_flag"
and"different_flag"
respectively.The target
//:cat
is built twice and cached under different action cache keyswhen building these transition targets, even though
//:cat
does not depend onthe build setting.
The CAS key is of course the same, as the contents of the output are the same.
Preferably,
//:cat
would only be built once in the transition case.What operating system are you running Bazel on?
Ubuntu 20.10
What's the output of
bazel info release
?release 4.0.0
Have you found anything relevant by searching the web?
This seems to be the same issue as reported on the following mailing list thread: https://groups.google.com/g/bazel-discuss/c/zVEc7gzbyu0/m/5UcZ8aXOBQAJ .
This seems to fall under the following umbrella issue: #6526 .
I decided to create a dedicated issue nonetheless, since I didn't see the specific issue of dependencies that don't depend on the build setting being rebuilt and cached separately on the issue tracker.
As I understand, #12568 suggests to address this issue through the setting's visibility attribute. However, that seems like a coarse approximation in general. A setting with public visibility might still only affect few targets.
Any other information, logs, or outputs that you want to share?
The use-case that prompted this issue is using user defined build settings to define feature flags. We then want to test different settings of feature flags in the same
bazel test //...
run, so we define transitions to generate targets that pin the feature flags. This causes unrelated dependencies to be rebuilt, e.g. core dependencies like com_google_protobuf. Ideally, only targets that directly depend on the feature flag, or transitively depend on a target that depends on the feature flag would be rebuilt.The text was updated successfully, but these errors were encountered: