aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/ActionInputPrefetcher.java7
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java18
2 files changed, 21 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/ActionInputPrefetcher.java b/src/main/java/com/google/devtools/build/lib/exec/ActionInputPrefetcher.java
index 84eb09a45f..23c9c0cf6d 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/ActionInputPrefetcher.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/ActionInputPrefetcher.java
@@ -17,6 +17,13 @@ import com.google.devtools.build.lib.actions.ActionInput;
/** Prefetches files to local disk. */
public interface ActionInputPrefetcher {
+ public static final ActionInputPrefetcher NONE =
+ new ActionInputPrefetcher() {
+ @Override
+ public void prefetchFile(ActionInput input) {
+ // Do nothing.
+ }
+ };
/**
* Initiates best-effort prefetching of the given input. This should not block.
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
index c96c5a0b0a..e437180d09 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -20,6 +20,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.eventbus.EventBus;
+import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.PackageRootResolver;
import com.google.devtools.build.lib.actions.cache.ActionCache;
import com.google.devtools.build.lib.actions.cache.CompactPersistentActionCache;
@@ -90,7 +91,7 @@ public final class CommandEnvironment {
private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT;
private long commandStartTime;
private OutputService outputService;
- private ImmutableList<ActionInputPrefetcher> actionInputPrefetchers = ImmutableList.of();
+ private ActionInputPrefetcher actionInputPrefetcher;
private Path workingDirectory;
private String commandName;
@@ -344,8 +345,8 @@ public final class CommandEnvironment {
return outputService;
}
- public ImmutableList<ActionInputPrefetcher> getActionInputPrefetchers() {
- return actionInputPrefetchers;
+ public ActionInputPrefetcher getActionInputPrefetcher() {
+ return actionInputPrefetcher == null ? ActionInputPrefetcher.NONE : actionInputPrefetcher;
}
public ActionCache getPersistentActionCache() throws IOException {
@@ -564,7 +565,16 @@ public final class CommandEnvironment {
prefetchersBuilder.add(actionInputPrefetcher);
}
}
- actionInputPrefetchers = prefetchersBuilder.build();
+ final ImmutableList<ActionInputPrefetcher> actionInputPrefetchers = prefetchersBuilder.build();
+ actionInputPrefetcher =
+ new ActionInputPrefetcher() {
+ @Override
+ public void prefetchFile(ActionInput input) {
+ for (ActionInputPrefetcher prefetcher : actionInputPrefetchers) {
+ prefetcher.prefetchFile(input);
+ }
+ }
+ };
SkyframeExecutor skyframeExecutor = getSkyframeExecutor();
skyframeExecutor.setOutputService(outputService);