From 5411129bae8e3f7ec6975ecbdf5c1cc04b50ec65 Mon Sep 17 00:00:00 2001 From: Janak Ramakrishnan Date: Wed, 9 Sep 2015 21:44:07 +0000 Subject: Delay cleaning of in-flight nodes until the following build. This allows us to interrupt evaluation in constant time. Some ParallelEvaluator tests that implicitly relied on cleaning happening before the next evaluation were moved into MemoizingEvaluatorTest as a result. -- MOS_MIGRATED_REVID=102696653 --- .../build/skyframe/InMemoryMemoizingEvaluator.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java') diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java index 324be40ee4..87db734938 100644 --- a/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java +++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java @@ -17,6 +17,7 @@ import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; +import com.google.common.base.Receiver; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; @@ -30,6 +31,7 @@ import com.google.devtools.build.skyframe.InvalidatingNodeVisitor.InvalidationSt import com.google.devtools.build.skyframe.NodeEntry.DependencyState; import java.io.PrintStream; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; @@ -157,9 +159,29 @@ public final class InMemoryMemoizingEvaluator implements MemoizingEvaluator { performInvalidation(); injectValues(intVersion); - ParallelEvaluator evaluator = new ParallelEvaluator(graph, intVersion, - skyFunctions, eventHandler, emittedEventState, DEFAULT_STORED_EVENT_FILTER, keepGoing, - numThreads, progressReceiver, dirtyKeyTracker); + // We must delete all nodes that are still in-flight at the end of the evaluation (in case the + // evaluation is aborted for some reason). In order to quickly return control to the caller, + // we store the set of such nodes for deletion at the start of the next evaluation. + Receiver> lazyDeletingReceiver = + new Receiver>() { + @Override + public void accept(Collection skyKeys) { + valuesToDelete.addAll(skyKeys); + } + }; + ParallelEvaluator evaluator = + new ParallelEvaluator( + graph, + intVersion, + skyFunctions, + eventHandler, + emittedEventState, + DEFAULT_STORED_EVENT_FILTER, + keepGoing, + numThreads, + progressReceiver, + dirtyKeyTracker, + lazyDeletingReceiver); EvaluationResult result = evaluator.eval(roots); return EvaluationResult.builder() .mergeFrom(result) -- cgit v1.2.3