Prevent unnecessary duplicated calls to graph.getBatch() with the same set
of keys. That's just a waste.
RELNOTES: None.
@@ -66,7 +66,7 @@ import javax.annotation.Nullable;
* translating a set of requested top-level nodes into actions, or constructing an evaluation
* result. Derived classes should do this.
*/
-public abstract class AbstractParallelEvaluator {
+abstract class AbstractParallelEvaluator {
private static final Logger logger = Logger.getLogger(AbstractParallelEvaluator.class.getName());
final ProcessableGraph graph;
@@ -232,6 +232,7 @@ public abstract class AbstractParallelEvaluator {
graph.get(skyKey, Reason.RDEP_REMOVAL, ErrorTransienceValue.KEY).removeReverseDep(skyKey);
return DirtyOutcome.NEEDS_EVALUATION;
}
+ Map<SkyKey, ? extends NodeEntry> entriesToCheck = null;
if (!evaluatorContext.keepGoing()) {
// This check ensures that we maintain the invariant that if a node with an error is
// reached during a no-keep-going build, none of its currently building parents
@@ -240,8 +241,7 @@ public abstract class AbstractParallelEvaluator {
// is done, then it is the parent's responsibility to notice that, which we do here.
// We check the deps for errors so that we don't continue building this node if it has
// a child error.
- Map<SkyKey, ? extends NodeEntry> entriesToCheck =
- graph.getBatch(skyKey, Reason.OTHER, directDepsToCheck);
+ entriesToCheck = graph.getBatch(skyKey, Reason.OTHER, directDepsToCheck);
for (Map.Entry<SkyKey, ? extends NodeEntry> entry : entriesToCheck.entrySet()) {
NodeEntry nodeEntryToCheck = entry.getValue();
SkyValue valueMaybeWithMetadata = nodeEntryToCheck.getValueMaybeWithMetadata();
@@ -296,8 +296,11 @@ public abstract class AbstractParallelEvaluator {
unknownStatusDeps);
continue;
}
+ if (entriesToCheck == null || depsReport.hasInformation()) {
+ entriesToCheck = graph.getBatch(skyKey, Reason.ENQUEUING_CHILD, unknownStatusDeps);
+ }
handleKnownChildrenForDirtyNode(
- unknownStatusDeps, state, globalEnqueuedIndex.incrementAndGet());
+ unknownStatusDeps, entriesToCheck, state, globalEnqueuedIndex.incrementAndGet());
return DirtyOutcome.ALREADY_PROCESSED;
}
switch (state.getDirtyState()) {
@@ -348,10 +351,11 @@ public abstract class AbstractParallelEvaluator {
}
private void handleKnownChildrenForDirtyNode(
- Collection<SkyKey> knownChildren, NodeEntry state, int childEvaluationPriority)
+ Collection<SkyKey> knownChildren,
+ Map<SkyKey, ? extends NodeEntry> oldChildren,
+ NodeEntry state,
+ int childEvaluationPriority)
throws InterruptedException {
- Map<SkyKey, ? extends NodeEntry> oldChildren =
- graph.getBatch(skyKey, Reason.ENQUEUING_CHILD, knownChildren);
if (oldChildren.size() != knownChildren.size()) {
GraphInconsistencyReceiver inconsistencyReceiver =
evaluatorContext.getGraphInconsistencyReceiver();
@@ -670,7 +674,10 @@ public abstract class AbstractParallelEvaluator {
graph.createIfAbsentBatchAsync(
skyKey, Reason.RDEP_ADDITION, newDepsThatWerentInTheLastEvaluation);
handleKnownChildrenForDirtyNode(
- newDepsThatWereInTheLastEvaluation, state, childEvaluationPriority);
+ newDepsThatWereInTheLastEvaluation,
+ graph.getBatch(skyKey, Reason.ENQUEUING_CHILD, newDepsThatWereInTheLastEvaluation),
+ state,
+ childEvaluationPriority);
// Due to multi-threading, this can potentially cause the current node to be re-enqueued if
// all 'new' children of this node are already done. Therefore, there should not be any
