Skip to content

Commit e68a7d0

Browse files
justinhorvitzcopybara-github
authored andcommitted
Remove the --experimental_dynamic_configs flag.
PiperOrigin-RevId: 370507866
1 parent ce70892 commit e68a7d0

21 files changed

+181
-1354
lines changed

src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,6 @@ public List<Label> getActionListeners() {
748748
return options.actionListeners;
749749
}
750750

751-
/**
752-
* Returns whether we should trim configurations to only include the fragments needed to correctly
753-
* analyze a rule.
754-
*/
755-
public boolean trimConfigurations() {
756-
return options.configsMode == CoreOptions.ConfigsMode.ON;
757-
}
758-
759751
/**
760752
* <b>>Experimental feature:</b> if true, qualifying outputs use path prefixes based on their
761753
* content instead of the traditional <code>blaze-out/$CPU-$COMPILATION_MODE</code>.

src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java

Lines changed: 9 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616

1717
import com.google.common.annotations.VisibleForTesting;
1818
import com.google.common.base.Functions;
19-
import com.google.common.base.Joiner;
2019
import com.google.common.collect.ImmutableList;
2120
import com.google.common.collect.ImmutableMap;
22-
import com.google.common.collect.ImmutableSet;
2321
import com.google.common.collect.Multimap;
24-
import com.google.common.collect.Sets;
2522
import com.google.devtools.build.lib.analysis.ConfigurationsCollector;
2623
import com.google.devtools.build.lib.analysis.ConfigurationsResult;
2724
import com.google.devtools.build.lib.analysis.Dependency;
@@ -37,7 +34,6 @@
3734
import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition;
3835
import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition.TransitionException;
3936
import com.google.devtools.build.lib.cmdline.Label;
40-
import com.google.devtools.build.lib.events.Event;
4137
import com.google.devtools.build.lib.events.ExtendedEventHandler;
4238
import com.google.devtools.build.lib.events.StoredEventHandler;
4339
import com.google.devtools.build.lib.packages.Attribute;
@@ -47,8 +43,6 @@
4743
import com.google.devtools.build.lib.skyframe.BuildConfigurationValue;
4844
import com.google.devtools.build.lib.skyframe.PackageValue;
4945
import com.google.devtools.build.lib.skyframe.PlatformMappingValue;
50-
import com.google.devtools.build.lib.skyframe.TransitiveTargetKey;
51-
import com.google.devtools.build.lib.skyframe.TransitiveTargetValue;
5246
import com.google.devtools.build.lib.util.OrderedSetMultimap;
5347
import com.google.devtools.build.lib.vfs.PathFragment;
5448
import com.google.devtools.build.skyframe.SkyFunction;
@@ -59,7 +53,6 @@
5953
import java.util.Collection;
6054
import java.util.Comparator;
6155
import java.util.HashMap;
62-
import java.util.HashSet;
6356
import java.util.LinkedHashMap;
6457
import java.util.LinkedHashSet;
6558
import java.util.List;
@@ -73,10 +66,8 @@
7366
* <p>This involves:
7467
*
7568
* <ol>
76-
* <li>Patching a source configuration's options with the transition
77-
* <li>If {@link BuildConfiguration#trimConfigurations} is true, trimming configuration fragments
78-
* to only those needed by the destination target and its transitive dependencies
79-
* <li>Getting the destination configuration from Skyframe
69+
* <li>Patching a source configuration's options with the transition.
70+
* <li>Getting the destination configuration from Skyframe.
8071
* </ol>
8172
*
8273
* <p>For the work of determining the transition requests themselves, see {@link
@@ -141,9 +132,7 @@ private BuildConfiguration getCurrentConfiguration() {
141132
* order, but that involves more runtime in performance-critical code, so we won't make that
142133
* change without a clear need.
143134
*
144-
* <p>If {@link BuildConfiguration#trimConfigurations()} is true, these configurations only
145-
* contain the fragments needed by the dep and its transitive closure. Else they unconditionally
146-
* include all fragments.
135+
* <p>These configurations unconditionally include all fragments.
147136
*
148137
* <p>This method is heavily performance-optimized. Because {@link
149138
* com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction} calls it over every edge in
@@ -185,18 +174,8 @@ private ImmutableList<Dependency> resolveConfiguration(
185174
return ImmutableList.of(resolveHostTransition(dependencyBuilder, dependencyKey));
186175
}
187176

188-
// Figure out the required fragments for this dep and its transitive closure.
189-
Set<Class<? extends Fragment>> depFragments =
190-
getTransitiveFragments(dependencyKey.getLabel(), getCurrentConfiguration());
191-
192-
// TODO(gregce): remove the below call once we have confidence trimmed configurations always
193-
// provide needed fragments. This unnecessarily drags performance on the critical path (up
194-
// to 0.5% of total analysis time as profiled over a simple cc_binary).
195-
if (getCurrentConfiguration().trimConfigurations()) {
196-
checkForMissingFragments(dependencyKind.getAttribute(), dependencyKey, depFragments);
197-
}
198-
199-
return resolveGenericTransition(depFragments, dependencyBuilder, dependencyKey);
177+
return resolveGenericTransition(
178+
getCurrentConfiguration().getFragmentsMap().keySet(), dependencyBuilder, dependencyKey);
200179
}
201180

202181
private Dependency resolveNullTransition(
@@ -352,30 +331,6 @@ private ImmutableList<String> collectTransitionKeys(Attribute attribute)
352331
return ImmutableList.of();
353332
}
354333

355-
/**
356-
* Returns the configuration fragments required by a dep and its transitive closure. Returns null
357-
* if Skyframe dependencies aren't yet available.
358-
*
359-
* @param dep label of the dep to check
360-
* @param parentConfig configuration of the rule depending on the dep
361-
*/
362-
private ImmutableSet<Class<? extends Fragment>> getTransitiveFragments(
363-
Label dep, BuildConfiguration parentConfig)
364-
throws InterruptedException, ValueMissingException {
365-
if (!parentConfig.trimConfigurations()) {
366-
return parentConfig.getFragmentsMap().keySet();
367-
}
368-
SkyKey fragmentsKey = TransitiveTargetKey.of(dep);
369-
TransitiveTargetValue transitiveDepInfo = (TransitiveTargetValue) env.getValue(fragmentsKey);
370-
if (transitiveDepInfo == null) {
371-
// This should only be possible for tests. In actual runs, this was already called
372-
// as a routine part of the loading phase.
373-
// TODO(bazel-team): check this only occurs in a test context.
374-
throw new ValueMissingException();
375-
}
376-
return transitiveDepInfo.getTransitiveConfigFragments().toSet();
377-
}
378-
379334
/**
380335
* Applies a configuration transition over a set of build options.
381336
*
@@ -438,52 +393,17 @@ private static BuildOptions addDefaultStarlarkOptions(
438393
return optionsWithDefaults == null ? fromOptions : optionsWithDefaults.build();
439394
}
440395

441-
/**
442-
* Checks the config fragments required by a dep against the fragments in its actual
443-
* configuration. If any are missing, triggers a descriptive "missing fragments" error.
444-
*/
445-
private void checkForMissingFragments(
446-
Attribute attribute, DependencyKey dep, Set<Class<? extends Fragment>> expectedDepFragments)
447-
throws DependencyEvaluationException {
448-
Set<String> ctgFragmentNames = new HashSet<>();
449-
for (Fragment fragment : getCurrentConfiguration().getFragmentsMap().values()) {
450-
ctgFragmentNames.add(fragment.getClass().getSimpleName());
451-
}
452-
Set<String> depFragmentNames = new HashSet<>();
453-
for (Class<? extends Fragment> fragmentClass : expectedDepFragments) {
454-
depFragmentNames.add(fragmentClass.getSimpleName());
455-
}
456-
Set<String> missing = Sets.difference(depFragmentNames, ctgFragmentNames);
457-
if (!missing.isEmpty()) {
458-
String msg =
459-
String.format(
460-
"%s: dependency %s from attribute \"%s\" is missing required config fragments: %s",
461-
ctgValue.getLabel(),
462-
dep.getLabel(),
463-
attribute == null ? "(null)" : attribute.getName(),
464-
Joiner.on(", ").join(missing));
465-
env.getListener().handle(Event.error(msg));
466-
throw new DependencyEvaluationException(new InvalidConfigurationException(msg));
467-
}
468-
}
469-
470396
/**
471397
* This method allows resolution of configurations outside of a skyfunction call.
472398
*
473399
* <p>Unlike {@link #resolveConfigurations}, this doesn't expect the current context to be
474400
* evaluating dependencies of a parent target. So this method is also suitable for top-level
475401
* targets.
476402
*
477-
* <p>Resolution consists of two steps:
478-
*
479-
* <ol>
480-
* <li>Apply the per-target transitions specified in {@code targetsToEvaluate}. This can be
481-
* used, e.g., to apply {@link
482-
* com.google.devtools.build.lib.analysis.config.transitions.TransitionFactory}s over global
483-
* top-level configurations.
484-
* <li>(Optionally) trim configurations to only the fragments the targets actually need. This is
485-
* triggered by {@link BuildConfiguration#trimConfigurations}.
486-
* </ol>
403+
* <p>Resolution consists of applying the per-target transitions specified in {@code
404+
* targetsToEvaluate}. This can be used, e.g., to apply {@link
405+
* com.google.devtools.build.lib.analysis.config.transitions.TransitionFactory}s over global
406+
* top-level configurations.
487407
*
488408
* <p>Preserves the original input order (but merges duplicate nodes that might occur due to
489409
* top-level configuration transitions) . Uses original (untrimmed, pre-transition) configurations

src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -611,41 +611,6 @@ public String getTypeDescription() {
611611
+ "target_environment values.")
612612
public Label autoCpuEnvironmentGroup;
613613

614-
/** Values for --experimental_dynamic_configs. */
615-
public enum ConfigsMode {
616-
/**
617-
* Deprecated mode: Each configured target is evaluated with only the configuration fragments it
618-
* needs by loading the target graph and examining the transitive requirements for each target
619-
* before analysis begins.
620-
*
621-
* <p>To become a no-op soon: b/129289764
622-
*/
623-
ON,
624-
/** Default mode: Each configured target is evaluated with all fragments known to Blaze. */
625-
NOTRIM
626-
}
627-
628-
/** Converter for --experimental_dynamic_configs. */
629-
public static class ConfigsModeConverter extends EnumConverter<ConfigsMode> {
630-
public ConfigsModeConverter() {
631-
super(ConfigsMode.class, "configurations mode");
632-
}
633-
}
634-
635-
@Option(
636-
name = "experimental_dynamic_configs",
637-
defaultValue = "notrim",
638-
converter = ConfigsModeConverter.class,
639-
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
640-
effectTags = {
641-
OptionEffectTag.LOSES_INCREMENTAL_STATE,
642-
OptionEffectTag.BAZEL_INTERNAL_CONFIGURATION,
643-
OptionEffectTag.LOADING_AND_ANALYSIS,
644-
},
645-
metadataTags = {OptionMetadataTag.EXPERIMENTAL},
646-
help = "Instantiates build configurations with the specified properties")
647-
public ConfigsMode configsMode;
648-
649614
/** Values for --experimental_output_paths. */
650615
public enum OutputPathsMode {
651616
/** Use the production output path model. */
@@ -875,7 +840,7 @@ public enum IncludeConfigFragmentsEnum {
875840
/** Provide the fragments required <em>directly</em> by this rule. */
876841
DIRECT,
877842
/** Provide the fragments required by this rule and its transitive dependencies. */
878-
TRANSITIVE;
843+
TRANSITIVE
879844
}
880845

881846
/** Enum converter for --include_config_fragments_provider. */
@@ -896,7 +861,6 @@ public FragmentOptions getHost() {
896861
host.compilationMode = hostCompilationMode;
897862
host.isHost = true;
898863
host.isExec = false;
899-
host.configsMode = configsMode;
900864
host.outputPathsMode = outputPathsMode;
901865
host.enableRunfiles = enableRunfiles;
902866
host.executionInfoModifier = executionInfoModifier;

src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public SkyValue compute(SkyKey skyKey, Environment env)
355355
associatedConfiguredTargetAndData.fromConfiguredTarget(associatedTarget);
356356
aspectPathBuilder.add(aspect);
357357

358-
SkyframeDependencyResolver resolver = view.createDependencyResolver(env);
358+
SkyframeDependencyResolver resolver = new SkyframeDependencyResolver(env);
359359
NestedSetBuilder<Package> transitivePackagesForPackageRootResolution =
360360
storeTransitivePackagesForPackageRootResolution ? NestedSetBuilder.stableOrder() : null;
361361

src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,20 +245,9 @@ public SkyValue compute(SkyKey key, Environment env) throws ConfiguredTargetFunc
245245
: transitivePackagesForPackageRootResolution.build());
246246
}
247247

248-
// This line is only needed for accurate error messaging. Say this target has a circular
249-
// dependency with one of its deps. With this line, loading this target fails so Bazel
250-
// associates the corresponding error with this target, as expected. Without this line,
251-
// the first TransitiveTargetValue call happens on its dep (in trimConfigurations), so Bazel
252-
// associates the error with the dep, which is misleading.
253-
if (configuration != null
254-
&& configuration.trimConfigurations()
255-
&& env.getValue(TransitiveTargetKey.of(label)) == null) {
256-
return null;
257-
}
258-
259248
TargetAndConfiguration ctgValue = new TargetAndConfiguration(target, configuration);
260249

261-
SkyframeDependencyResolver resolver = view.createDependencyResolver(env);
250+
SkyframeDependencyResolver resolver = new SkyframeDependencyResolver(env);
262251

263252
ToolchainCollection<UnloadedToolchainContext> unloadedToolchainContexts = null;
264253

0 commit comments

Comments
 (0)