diff --git a/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java index 7fcf12c7f5043b..a84d1aba443970 100644 --- a/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java +++ b/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java @@ -20,6 +20,7 @@ import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -761,15 +762,17 @@ public void run() { // "newDeps" refers to newly discovered this time around after a SkyFunction#compute call // and not to be confused with the oldDeps variable which refers to the last evaluation, // i.e. a prior call to ParallelEvaluator#eval. - Set newDepsThatWerentInTheLastEvaluation; - Set newDepsThatWereInTheLastEvaluation; + Collection newDepsThatWerentInTheLastEvaluation; + ImmutableList newDepsThatWereInTheLastEvaluation; if (oldDeps.isEmpty()) { // When there are no old deps (clean evaluations), avoid set views which have O(n) size. newDepsThatWerentInTheLastEvaluation = newDeps; - newDepsThatWereInTheLastEvaluation = ImmutableSet.of(); + newDepsThatWereInTheLastEvaluation = ImmutableList.of(); } else { - newDepsThatWerentInTheLastEvaluation = Sets.difference(newDeps, oldDeps); - newDepsThatWereInTheLastEvaluation = Sets.intersection(newDeps, oldDeps); + newDepsThatWerentInTheLastEvaluation = + ImmutableList.copyOf(Sets.difference(newDeps, oldDeps)); + newDepsThatWereInTheLastEvaluation = + ImmutableList.copyOf(Sets.intersection(newDeps, oldDeps)); } InterruptibleSupplier newDepsThatWerentInTheLastEvaluationNodes = @@ -1026,15 +1029,14 @@ private boolean maybeHandleRegisteringNewlyDiscoveredDepsForDoneEntry( } env.addTemporaryDirectDepsTo(entry); - Set newlyAddedNewDeps; - Set previouslyRegisteredNewDeps; + Collection newlyAddedNewDeps; + ImmutableCollection previouslyRegisteredNewDeps; if (oldDeps.isEmpty()) { - // When there are no old deps (clean evaluations), avoid set views which have O(n) size. newlyAddedNewDeps = newDeps; previouslyRegisteredNewDeps = ImmutableSet.of(); } else { - newlyAddedNewDeps = Sets.difference(newDeps, oldDeps); - previouslyRegisteredNewDeps = Sets.intersection(newDeps, oldDeps); + newlyAddedNewDeps = ImmutableList.copyOf(Sets.difference(newDeps, oldDeps)); + previouslyRegisteredNewDeps = ImmutableList.copyOf(Sets.intersection(newDeps, oldDeps)); } InterruptibleSupplier newlyAddedNewDepNodes = diff --git a/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java b/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java index 8ce565f99f1508..7fc2e78020aeb8 100644 --- a/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java +++ b/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java @@ -885,7 +885,8 @@ Set commitAndGetParents(NodeEntry primaryEntry) throws InterruptedExcept GroupedDeps temporaryDirectDeps = primaryEntry.getTemporaryDirectDeps(); if (!oldDeps.isEmpty()) { // Remove the rdep on this entry for each of its old deps that is no longer a direct dep. - Set depsToRemove = Sets.difference(oldDeps, temporaryDirectDeps.toSet()); + ImmutableList depsToRemove = + ImmutableList.copyOf(Sets.difference(oldDeps, temporaryDirectDeps.toSet())); NodeBatch oldDepEntries = evaluatorContext.getGraph().getBatch(skyKey, Reason.RDEP_REMOVAL, depsToRemove); for (SkyKey key : depsToRemove) {