diff options
author | Eric Fellheimer <felly@google.com> | 2016-06-30 21:29:21 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2016-07-01 07:12:04 +0000 |
commit | 583f9e9d5a847affde188f0059b398fa016394d2 (patch) | |
tree | b1d294c5f4f176b0d479d9abcc45b011a61fa32a /src | |
parent | df726eae7b6ef11df3b962d720df36f63d5cd3a3 (diff) |
Batch prefetch now also retrieves the deps from the node's previous run.
--
MOS_MIGRATED_REVID=126344189
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java index aa3a0dc8de..d8c276405b 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java +++ b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java @@ -16,6 +16,7 @@ package com.google.devtools.build.skyframe; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.base.Throwables; @@ -106,6 +107,10 @@ public final class ParallelEvaluator implements Evaluator { private static final Logger LOG = Logger.getLogger(ParallelEvaluator.class.getName()); + private static final boolean PREFETCH_OLD_DEPS = + Boolean.parseBoolean( + System.getProperty("skyframe.ParallelEvaluator.PrefetchOldDeps", "true")); + /** Filters out events which should not be stored. */ public interface EventFilter extends Predicate<Event> { /** @@ -294,7 +299,7 @@ public final class ParallelEvaluator implements Evaluator { this.skyKey = skyKey; this.oldDeps = oldDeps; this.directDeps = Collections.unmodifiableMap( - batchPrefetch(directDeps, /*assertDone=*/bubbleErrorInfo == null, skyKey)); + batchPrefetch(directDeps, oldDeps, /*assertDone=*/bubbleErrorInfo == null, skyKey)); this.bubbleErrorInfo = bubbleErrorInfo; this.visitor = visitor; Preconditions.checkState( @@ -304,14 +309,26 @@ public final class ParallelEvaluator implements Evaluator { } private Map<SkyKey, NodeEntry> batchPrefetch( - GroupedList<SkyKey> keys, boolean assertDone, SkyKey keyForDebugging) { - Map<SkyKey, NodeEntry> batchMap = graph.getBatch(Iterables.concat(keys)); - if (batchMap.size() != keys.numElements()) { + GroupedList<SkyKey> depKeys, Set<SkyKey> oldDeps, boolean assertDone, + SkyKey keyForDebugging) { + Iterable<SkyKey> depKeysAsIterable = Iterables.concat(depKeys); + Iterable<SkyKey> keysToPrefetch = depKeysAsIterable; + if (PREFETCH_OLD_DEPS) { + ImmutableSet.Builder<SkyKey> keysToPrefetchBuilder = ImmutableSet.builder(); + keysToPrefetchBuilder.addAll(depKeysAsIterable).addAll(oldDeps); + keysToPrefetch = keysToPrefetchBuilder.build(); + } + Map<SkyKey, NodeEntry> batchMap = graph.getBatch(keysToPrefetch); + if (PREFETCH_OLD_DEPS) { + batchMap = ImmutableMap.copyOf( + Maps.filterKeys(batchMap, Predicates.in(ImmutableSet.copyOf(depKeysAsIterable)))); + } + if (batchMap.size() != depKeys.numElements()) { throw new IllegalStateException( "Missing keys for " + keyForDebugging + ": " - + Sets.difference(keys.toSet(), batchMap.keySet())); + + Sets.difference(depKeys.toSet(), batchMap.keySet())); } if (assertDone) { for (Map.Entry<SkyKey, NodeEntry> entry : batchMap.entrySet()) { |