aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-04-30 16:18:50 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-30 16:19:58 -0700
commit46706aef724c69016d9eae914cbe7a96349442c2 (patch)
treefdf8821a7077f4c973d0806bcbf21fdba9e4f158 /src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
parentb9f8627289294407ef93efda894ce138f1881a38 (diff)
Allow SkyFunctions to return a sentinel value indicating that all of a node's in-progress data should be forgotten, and its evaluation should be restarted from scratch, as if it were freshly created/dirtied. To guard against this happening unexpectedly, any such events are passed to a GraphInconsistencyReceiver, which can verify that the SkyFunction is behaving properly.
This is the first change in a series to permit action rewinding when it is discovered that a previously generated input file is no longer available. When an action detects that one of its inputs is unusable, it can return this sentinel value, causing it to be re-evaluated from scratch. Follow-up changes will make the node corresponding to the input, and the node corresponding to the action that generated the input, dirty when this happens, causing the upstream action to be re-run, regenerating the desired input. Currently works for builds that do not keep edges, although follow-ups may make this possible for all builds. PiperOrigin-RevId: 194863097
Diffstat (limited to 'src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java')
-rw-r--r--src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java78
1 files changed, 47 insertions, 31 deletions
diff --git a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
index 6860433c01..14306d484b 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
+++ b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
@@ -52,6 +52,7 @@ class ParallelEvaluatorContext {
private final DirtyTrackingProgressReceiver progressReceiver;
private final EventFilter storedEventFilter;
private final ErrorInfoManager errorInfoManager;
+ private final GraphInconsistencyReceiver graphInconsistencyReceiver;
/**
* The visitor managing the thread pool. Used to enqueue parents when an entry is finished, and,
@@ -72,29 +73,20 @@ class ParallelEvaluatorContext {
EventFilter storedEventFilter,
ErrorInfoManager errorInfoManager,
final Function<SkyKey, Runnable> runnableMaker,
+ GraphInconsistencyReceiver graphInconsistencyReceiver,
final int threadCount) {
- this.graph = graph;
- this.graphVersion = graphVersion;
- this.skyFunctions = skyFunctions;
- this.reporter = reporter;
- this.replayingNestedSetEventVisitor =
- new NestedSetVisitor<>(new NestedSetEventReceiver(reporter), emittedEventState.eventState);
- this.replayingNestedSetPostableVisitor =
- new NestedSetVisitor<>(
- new NestedSetPostableReceiver(reporter), emittedEventState.postableState);
- this.keepGoing = keepGoing;
- this.progressReceiver = Preconditions.checkNotNull(progressReceiver);
- this.storedEventFilter = storedEventFilter;
- this.errorInfoManager = errorInfoManager;
- visitorSupplier =
- Suppliers.memoize(
- new Supplier<NodeEntryVisitor>() {
- @Override
- public NodeEntryVisitor get() {
- return new NodeEntryVisitor(
- threadCount, progressReceiver, runnableMaker);
- }
- });
+ this(
+ graph,
+ graphVersion,
+ skyFunctions,
+ reporter,
+ emittedEventState,
+ keepGoing,
+ progressReceiver,
+ storedEventFilter,
+ errorInfoManager,
+ graphInconsistencyReceiver,
+ () -> new NodeEntryVisitor(threadCount, progressReceiver, runnableMaker));
}
ParallelEvaluatorContext(
@@ -108,11 +100,39 @@ class ParallelEvaluatorContext {
EventFilter storedEventFilter,
ErrorInfoManager errorInfoManager,
final Function<SkyKey, Runnable> runnableMaker,
+ GraphInconsistencyReceiver graphInconsistencyReceiver,
final ForkJoinPool forkJoinPool) {
+ this(
+ graph,
+ graphVersion,
+ skyFunctions,
+ reporter,
+ emittedEventState,
+ keepGoing,
+ progressReceiver,
+ storedEventFilter,
+ errorInfoManager,
+ graphInconsistencyReceiver,
+ () -> new NodeEntryVisitor(forkJoinPool, progressReceiver, runnableMaker));
+ }
+
+ private ParallelEvaluatorContext(
+ QueryableGraph graph,
+ Version graphVersion,
+ ImmutableMap<SkyFunctionName, ? extends SkyFunction> skyFunctions,
+ ExtendedEventHandler reporter,
+ EmittedEventState emittedEventState,
+ boolean keepGoing,
+ final DirtyTrackingProgressReceiver progressReceiver,
+ EventFilter storedEventFilter,
+ ErrorInfoManager errorInfoManager,
+ GraphInconsistencyReceiver graphInconsistencyReceiver,
+ Supplier<NodeEntryVisitor> visitorSupplier) {
this.graph = graph;
this.graphVersion = graphVersion;
this.skyFunctions = skyFunctions;
this.reporter = reporter;
+ this.graphInconsistencyReceiver = graphInconsistencyReceiver;
this.replayingNestedSetEventVisitor =
new NestedSetVisitor<>(new NestedSetEventReceiver(reporter), emittedEventState.eventState);
this.replayingNestedSetPostableVisitor =
@@ -122,15 +142,7 @@ class ParallelEvaluatorContext {
this.progressReceiver = Preconditions.checkNotNull(progressReceiver);
this.storedEventFilter = storedEventFilter;
this.errorInfoManager = errorInfoManager;
- visitorSupplier =
- Suppliers.memoize(
- new Supplier<NodeEntryVisitor>() {
- @Override
- public NodeEntryVisitor get() {
- return new NodeEntryVisitor(
- forkJoinPool, progressReceiver, runnableMaker);
- }
- });
+ this.visitorSupplier = Suppliers.memoize(visitorSupplier);
}
Map<SkyKey, ? extends NodeEntry> getBatchValues(
@@ -196,6 +208,10 @@ class ParallelEvaluatorContext {
return progressReceiver;
}
+ GraphInconsistencyReceiver getGraphInconsistencyReceiver() {
+ return graphInconsistencyReceiver;
+ }
+
NestedSetVisitor<TaggedEvents> getReplayingNestedSetEventVisitor() {
return replayingNestedSetEventVisitor;
}