aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java
diff options
context:
space:
mode:
authorGravatar Janak Ramakrishnan <janakr@google.com>2015-09-09 21:44:07 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-09-11 08:46:08 +0000
commit5411129bae8e3f7ec6975ecbdf5c1cc04b50ec65 (patch)
tree9cc38bbabbd234e8c465c9a03e6b688dc3537153 /src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java
parent162b4410d7b82021e8ffa2197a076d9ba6332ca7 (diff)
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/InMemoryMemoizingEvaluator.java28
1 files changed, 25 insertions, 3 deletions
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<Collection<SkyKey>> lazyDeletingReceiver =
+ new Receiver<Collection<SkyKey>>() {
+ @Override
+ public void accept(Collection<SkyKey> skyKeys) {
+ valuesToDelete.addAll(skyKeys);
+ }
+ };
+ ParallelEvaluator evaluator =
+ new ParallelEvaluator(
+ graph,
+ intVersion,
+ skyFunctions,
+ eventHandler,
+ emittedEventState,
+ DEFAULT_STORED_EVENT_FILTER,
+ keepGoing,
+ numThreads,
+ progressReceiver,
+ dirtyKeyTracker,
+ lazyDeletingReceiver);
EvaluationResult<T> result = evaluator.eval(roots);
return EvaluationResult.<T>builder()
.mergeFrom(result)