diff options
author | 2018-01-24 08:43:35 -0800 | |
---|---|---|
committer | 2018-01-24 08:44:59 -0800 | |
commit | a39a562850bc17182d2ee0d86177457f27453bef (patch) | |
tree | 29077fc35356e20034b0402e546a157faebd4d02 /src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java | |
parent | 86d206129aae21567c3d7e6adba7d3939970b019 (diff) |
Introduce a wrapper around the ImmutableSortedSet<Class<? extends BuildConfiguration.Fragment>> set of Fragment classes that is part of the BuildConfigurationValue.Key. This class allows us to compute a fingerprint of the wrapped ImmutableSortedSet, making equality comparisons fast. The number of additional wrapper objects is the number of distinct sets of fragment classes, so 1. (In fact, we don't even need to compute a fingerprint, since reference equality does the job for us here, but we do it just to be conservative.)
This CL has a performance benefit for Bazel currently, but has a bigger performance benefit in the following changes, where there are more BuildConfigurationValue.Key objects to compare.
PiperOrigin-RevId: 183090122
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java index 249ac0c5e4..57cf02b1f1 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/ConfigurationResolver.java @@ -19,7 +19,6 @@ import com.google.common.base.Joiner; import com.google.common.base.Verify; import com.google.common.base.VerifyException; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedListMultimap; @@ -123,8 +122,7 @@ public final class ConfigurationResolver { Map<FragmentsAndTransition, List<BuildOptions>> transitionsMap = new LinkedHashMap<>(); // The fragments used by the current target's configuration. - ImmutableSortedSet<Class<? extends BuildConfiguration.Fragment>> ctgFragments = - ctgValue.getConfiguration().fragmentClasses(); + FragmentClassSet ctgFragments = ctgValue.getConfiguration().fragmentClasses(); BuildOptions ctgOptions = ctgValue.getConfiguration().getOptions(); // Stores the configuration-resolved versions of each dependency. This method must preserve the @@ -183,7 +181,7 @@ public final class ConfigurationResolver { depFragments); } - boolean sameFragments = depFragments.equals(ctgFragments); + boolean sameFragments = depFragments.equals(ctgFragments.fragmentClasses()); Transition transition = dep.getTransition(); if (sameFragments) { @@ -233,9 +231,12 @@ public final class ConfigurationResolver { // If we get here, we have to get the configuration from Skyframe. for (BuildOptions options : toOptions) { - keysToEntries.put( - BuildConfigurationValue.key(sameFragments ? ctgFragments : depFragments, options), - depsEntry); + if (sameFragments) { + keysToEntries.put(BuildConfigurationValue.key(ctgFragments, options), depsEntry); + + } else { + keysToEntries.put(BuildConfigurationValue.key(depFragments, options), depsEntry); + } } } |