aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-08-13 16:13:42 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-13 16:15:46 -0700
commit6ae05b419922193c4c253e51c9a5e483e4f947fa (patch)
treee06491f807689124cad73a2011af2db821e390e1 /src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
parentce170540ba5401e926a5433e6e35b1d22426e525 (diff)
Order Skyframe evaluations in a priority queue, with all children of a given node having the same priority, later enqueueings having higher priority, re-enqueued nodes having highest priority, and new root nodes having lowest priority. Experimentally, this can save significant RAM (1.4G in some builds!) while not affecting speed.
Also do a semi-drive-by deleting ExecutorFactory parameter to AbstractQueueVisitor, since it was always AbstractQueueVisitor.EXECUTOR_FACTORY. PiperOrigin-RevId: 208560889
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.java19
1 files changed, 15 insertions, 4 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 60987ac7f2..db2afd10e5 100644
--- a/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
+++ b/src/main/java/com/google/devtools/build/skyframe/ParallelEvaluatorContext.java
@@ -13,7 +13,6 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
-import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
@@ -73,7 +72,7 @@ class ParallelEvaluatorContext {
final DirtyTrackingProgressReceiver progressReceiver,
EventFilter storedEventFilter,
ErrorInfoManager errorInfoManager,
- final Function<SkyKey, Runnable> runnableMaker,
+ RunnableMaker runnableMaker,
GraphInconsistencyReceiver graphInconsistencyReceiver,
final int threadCount) {
this(
@@ -101,7 +100,7 @@ class ParallelEvaluatorContext {
final DirtyTrackingProgressReceiver progressReceiver,
EventFilter storedEventFilter,
ErrorInfoManager errorInfoManager,
- final Function<SkyKey, Runnable> runnableMaker,
+ RunnableMaker runnableMaker,
GraphInconsistencyReceiver graphInconsistencyReceiver,
final ForkJoinPool forkJoinPool,
EvaluationVersionBehavior evaluationVersionBehavior) {
@@ -120,6 +119,18 @@ class ParallelEvaluatorContext {
evaluationVersionBehavior);
}
+ /**
+ * Returns a {@link Runnable} given a {@code key} to evaluate and an {@code evaluationPriority}
+ * indicating whether it should be scheduled for evaluation soon (higher is better). The returned
+ * {@link Runnable} is a {@link ComparableRunnable} so that it can be ordered by {@code
+ * evaluationPriority} in a priority queue if needed.
+ */
+ interface RunnableMaker {
+ ComparableRunnable make(SkyKey key, int evaluationPriority);
+ }
+
+ interface ComparableRunnable extends Runnable, Comparable<ComparableRunnable> {}
+
private ParallelEvaluatorContext(
QueryableGraph graph,
Version graphVersion,
@@ -174,7 +185,7 @@ class ParallelEvaluatorContext {
for (SkyKey key : keys) {
NodeEntry entry = Preconditions.checkNotNull(batch.get(key), key);
if (entry.signalDep(version)) {
- getVisitor().enqueueEvaluation(key);
+ getVisitor().enqueueEvaluation(key, Integer.MAX_VALUE);
}
}
return;