Make Skyframe external computations and rewinding compatible
When resetting a node during rewinding, reset its externalDeps counter
along with its signaledDeps and dirtyDirectDepIndex counters.
When processing a Restart value returned from a SkyFunction#compute
call, the evaluation framework (i.e. AbstractParallelEvaluator.Evaluate)
will cancel any newly depended-on incomplete futures. We believe it is
preferable to cancel external computation whose results may not be used
in such a scenario.
Async action execution does not (currently) make it possible to register
an dep on an incomplete future and then return a Restart. Futures may be
depended on in two ways:
1. In ActionExecutionState#getResultOrDependOnFuture, a future may be
depended on if the action is shared and owned by another Skyframe node.
If so, #getResultOrDependOnFuture returns null, and no other significant
work is done before that null is returned from
ActionExecutionFunction#compute.
2. In ActionContinuationStep#run (in SkyframeActionExecutor.java), a
future may be depended on if the step's actionContinuationOrResult's
future is not done. This #run method is called from
ActionExecutionState#runStateMachine. Immediately afterwards,
env.valuesMissing() is called, and null is returned from #runStateMachine
if #valuesMissing returned true. No significant work is done before that
null is returned from ActionExecutionFunction#compute.
RELNOTES: None.
PiperOrigin-RevId: 247261978
diff --git a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
index 4b348b9..81e9dc6 100644
--- a/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
+++ b/src/main/java/com/google/devtools/build/skyframe/InMemoryNodeEntry.java
@@ -691,8 +691,7 @@
@Override
public synchronized void resetForRestartFromScratch() {
- Preconditions.checkState(!isDone(), "Reset entry can't be done: %s", this);
- Preconditions.checkState(isEvaluating());
+ Preconditions.checkState(isReady(), this);
directDeps = null;
dirtyBuildingState.resetForRestartFromScratch();
}