From de281a77a68490dba35063d901055ef248138d37 Mon Sep 17 00:00:00 2001 From: Janak Ramakrishnan Date: Thu, 24 Sep 2015 21:12:05 +0000 Subject: Prefetch and assert done on direct deps. Also print a more informative error message if a previously known direct dep isn't done. -- MOS_MIGRATED_REVID=103880990 --- .../devtools/build/skyframe/ParallelEvaluator.java | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/main/java') 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 a2df93a2ed..c7f8db9f07 100644 --- a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java +++ b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluator.java @@ -329,8 +329,17 @@ public final class ParallelEvaluator implements Evaluator { builder.put(depKey, ValueOrExceptionUtils.ofNull()); continue; } - Preconditions.checkState(!directDeps.contains(depKey), "%s %s %s", skyKey, depKey, - value); + if (directDeps.contains(depKey)) { + throw new IllegalStateException( + "Undone key " + + depKey + + " was already in deps of " + + skyKey + + "( dep: " + + graph.get(depKey) + + ", parent: " + + graph.get(skyKey)); + } addDep(depKey); valuesMissing = true; builder.put(depKey, ValueOrExceptionUtils.ofNull()); @@ -608,6 +617,20 @@ public final class ParallelEvaluator implements Evaluator { NEEDS_EVALUATION } + // Take advantage of graphs that cache batch requests and prefetch keys that will be needed. + private static void batchPrefetchAndAssertDone( + Set keys, QueryableGraph graph, SkyKey keyForDebugging) { + Map batchMap = graph.getBatch(keys); + if (batchMap.size() != keys.size()) { + throw new IllegalStateException( + "Missing keys for " + keyForDebugging + ": " + Sets.difference(keys, batchMap.keySet())); + } + for (Map.Entry entry : batchMap.entrySet()) { + Preconditions.checkState( + entry.getValue().isDone(), "%s had not done %s", keyForDebugging, entry); + } + } + /** * An action that evaluates a value. */ @@ -774,6 +797,7 @@ public final class ParallelEvaluator implements Evaluator { Set directDeps = state.getTemporaryDirectDeps(); Preconditions.checkState(!directDeps.contains(ErrorTransienceValue.key()), "%s cannot have a dep on ErrorTransienceValue during building: %s", skyKey, state); + batchPrefetchAndAssertDone(directDeps, graph, skyKey); // Get the corresponding SkyFunction and call it on this value. SkyFunctionEnvironment env = new SkyFunctionEnvironment(skyKey, directDeps, visitor); SkyFunctionName functionName = skyKey.functionName(); -- cgit v1.2.3