A bunch of small changes to prepare SkyQueryEnvironment for full-parallel evaluation:
-Rename QueryExpression#evalConcurrently to QueryExpression#parEval. (parallelism is not concurrency! See https://existentialtype.wordpress.com/2011/03/17/parallelism-is-not-concurrency/)
-Have SkyQueryEnvironment#eval (used recursively in #evaluateQuery) dynamically call QueryExpression#parEval when appropriate.
-Delete QueryExpression#canEvalConcurrently.
-Add ThreadSafety annotations in a bunch of relevant places in the query codebase.
-A bunch of testing infrastructure to test parallel query evaluation.
-TODOs for implementing parallel evaluation of all QueryExpression nodes.
--
MOS_MIGRATED_REVID=132436340
diff --git a/src/main/java/com/google/devtools/build/lib/query2/AbstractBlazeQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/AbstractBlazeQueryEnvironment.java
index 769bdb2..cd597a6 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/AbstractBlazeQueryEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/AbstractBlazeQueryEnvironment.java
@@ -30,6 +30,7 @@
import com.google.devtools.build.lib.query2.engine.QueryEvalResult;
import com.google.devtools.build.lib.query2.engine.QueryException;
import com.google.devtools.build.lib.query2.engine.QueryExpression;
+import com.google.devtools.build.lib.query2.engine.QueryExpressionEvalListener;
import com.google.devtools.build.lib.query2.engine.QueryUtil.AggregateAllCallback;
import com.google.devtools.build.lib.query2.engine.VariableContext;
import com.google.devtools.build.lib.util.Preconditions;
@@ -55,6 +56,7 @@
private final Set<Setting> settings;
private final List<QueryFunction> extraFunctions;
+ private final QueryExpressionEvalListener<T> evalListener;
private static final Logger LOG = Logger.getLogger(AbstractBlazeQueryEnvironment.class.getName());
@@ -63,7 +65,8 @@
Predicate<Label> labelFilter,
EventHandler eventHandler,
Set<Setting> settings,
- Iterable<QueryFunction> extraFunctions) {
+ Iterable<QueryFunction> extraFunctions,
+ QueryExpressionEvalListener<T> evalListener) {
this.eventHandler = new ErrorSensingEventHandler(eventHandler);
this.keepGoing = keepGoing;
this.strictScope = strictScope;
@@ -71,6 +74,7 @@
this.labelFilter = labelFilter;
this.settings = Sets.immutableEnumSet(settings);
this.extraFunctions = ImmutableList.copyOf(extraFunctions);
+ this.evalListener = evalListener;
}
private static DependencyFilter constructDependencyFilter(
@@ -213,4 +217,9 @@
builder.addAll(extraFunctions);
return builder.build();
}
+
+ @Override
+ public QueryExpressionEvalListener<T> getEvalListener() {
+ return evalListener;
+ }
}