|
16 | 16 | import static com.google.common.base.Preconditions.checkNotNull;
|
17 | 17 |
|
18 | 18 | import com.google.common.base.Suppliers;
|
19 |
| -import com.google.common.collect.MapMaker; |
| 19 | +import com.google.common.collect.ImmutableList; |
20 | 20 | import com.google.devtools.build.lib.actions.ActionExecutionException;
|
21 | 21 | import com.google.devtools.build.lib.actions.Artifact;
|
22 | 22 | import com.google.devtools.build.lib.collect.nestedset.NestedSet;
|
23 | 23 | import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
|
24 |
| -import com.google.devtools.build.lib.concurrent.BlazeInterners; |
25 | 24 | import com.google.devtools.build.lib.skyframe.ArtifactFunction.SourceArtifactException;
|
26 | 25 | import com.google.devtools.build.lib.util.Pair;
|
27 | 26 | import com.google.devtools.build.skyframe.SkyFunction;
|
@@ -82,17 +81,6 @@ final class ArtifactNestedSetFunction implements SkyFunction {
|
82 | 81 | */
|
83 | 82 | private ConcurrentMap<SkyKey, SkyValue> artifactSkyKeyToSkyValue = new ConcurrentHashMap<>();
|
84 | 83 |
|
85 |
| - /** |
86 |
| - * Maps the NestedSets' underlying objects to the corresponding SkyKey. This is to avoid |
87 |
| - * re-creating SkyKey for the same nested set upon reevaluation because of e.g. a missing value. |
88 |
| - * |
89 |
| - * <p>The map weakly references its values: when the ArtifactNestedSetKey becomes otherwise |
90 |
| - * unreachable, the entry is collected. |
91 |
| - */ |
92 |
| - // Note: Not using a caffeine cache here because it used more memory (b/193294367). |
93 |
| - private final ConcurrentMap<NestedSet.Node, ArtifactNestedSetKey> nestedSetToSkyKey = |
94 |
| - new MapMaker().concurrencyLevel(BlazeInterners.concurrencyLevel()).weakValues().makeMap(); |
95 |
| - |
96 | 84 | private final Supplier<ArtifactNestedSetValue> valueSupplier;
|
97 | 85 |
|
98 | 86 | private static ArtifactNestedSetFunction singleton = null;
|
@@ -162,17 +150,15 @@ public SkyValue compute(SkyKey skyKey, Environment env)
|
162 | 150 | }
|
163 | 151 |
|
164 | 152 | private List<SkyKey> getDepSkyKeys(ArtifactNestedSetKey skyKey) {
|
165 |
| - List<Artifact> leaves = skyKey.getSet().getLeaves(); |
166 |
| - List<NestedSet<Artifact>> nonLeaves = skyKey.getSet().getNonLeaves(); |
| 153 | + ImmutableList<Artifact> leaves = skyKey.getSet().getLeaves(); |
| 154 | + ImmutableList<NestedSet<Artifact>> nonLeaves = skyKey.getSet().getNonLeaves(); |
167 | 155 |
|
168 | 156 | List<SkyKey> keys = new ArrayList<>(leaves.size() + nonLeaves.size());
|
169 | 157 | for (Artifact file : leaves) {
|
170 | 158 | keys.add(Artifact.key(file));
|
171 | 159 | }
|
172 | 160 | for (NestedSet<Artifact> nonLeaf : nonLeaves) {
|
173 |
| - keys.add( |
174 |
| - nestedSetToSkyKey.computeIfAbsent( |
175 |
| - nonLeaf.toNode(), node -> new ArtifactNestedSetKey(nonLeaf, node))); |
| 161 | + keys.add(ArtifactNestedSetKey.create(nonLeaf)); |
176 | 162 | }
|
177 | 163 | return keys;
|
178 | 164 | }
|
|
0 commit comments