Automated rollback of commit 37deb2685b278e7f19b1aee5a77ca9fc601860a3. *** Reason for rollback *** Rolling the original forward unchanged, it was not in fact the root cause for the problem it was identified for. *** Original change description *** Automated rollback of commit 0c2ddc499d9fafa99ab3298b7eabdafb59946bfd. *** Reason for rollback *** Can cause duplicate action conflicts *** Original change description *** Query performance: skip attributes w/o labels Before: 0m16.264s 0m6.002s 0m4.928s 0m5.186s After: 0m14.313s 0m6.017s 0m5.458s 0m5.301s PiperOrigin-RevId: 249111272
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java index ad97ec3..eb7d0bd 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java
@@ -26,6 +26,7 @@ import com.google.devtools.build.lib.packages.BuildType.Selector; import com.google.devtools.build.lib.packages.BuildType.SelectorList; import com.google.devtools.build.lib.syntax.Type; +import com.google.devtools.build.lib.syntax.Type.LabelClass; import com.google.devtools.build.lib.syntax.Type.ListType; import java.util.ArrayList; import java.util.Collection; @@ -80,6 +81,9 @@ Type<?> type = attribute.getType(); SelectorList<?> selectorList = getSelectorList(attribute.getName(), type); if (selectorList == null) { + if (type.getLabelClass().equals(LabelClass.NONE)) { + return; // Skip non-label attributes for performance. + } if (getComputedDefault(attribute.getName(), attribute.getType()) != null) { // Computed defaults are a special pain: we have no choice but to iterate through their // (computed) values and look for labels.
diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index 37a2b7c..86730ac 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java
@@ -43,6 +43,7 @@ import com.google.devtools.build.lib.events.EventHandler; import com.google.devtools.build.lib.events.Location; import com.google.devtools.build.lib.events.NullEventHandler; +import com.google.devtools.build.lib.packages.Attribute.ComputedDefault; import com.google.devtools.build.lib.packages.Attribute.SkylarkComputedDefaultTemplate; import com.google.devtools.build.lib.packages.Attribute.SkylarkComputedDefaultTemplate.CannotPrecomputeDefaultsException; import com.google.devtools.build.lib.packages.BuildType.LabelConversionContext; @@ -2091,6 +2092,13 @@ if (defaultValue instanceof SkylarkComputedDefaultTemplate) { SkylarkComputedDefaultTemplate template = (SkylarkComputedDefaultTemplate) defaultValue; valueToSet = template.computePossibleValues(attr, rule, eventHandler); + } else if (defaultValue instanceof ComputedDefault) { + // Compute all possible values to verify that the ComputedDefault is well-defined. This was + // previously done implicitly as part of visiting all labels to check for null-ness in + // Rule.checkForNullLabels, but that was changed to skip non-label attributes to improve + // performance. + ((ComputedDefault) defaultValue).getPossibleValues(attr.getType(), rule); + valueToSet = defaultValue; } else { valueToSet = defaultValue; }