From d5500a29b61764b76c09f36542ba506b9ed083ec Mon Sep 17 00:00:00 2001 From: Ulf Adams Date: Wed, 16 Nov 2016 09:54:55 +0000 Subject: Merge all action input prefetchers into a single one. It seems unnecessary to pass these lists around, so this should simplify the APIs. Also, I want to move the action input prefetcher setup to the serverInit call. -- MOS_MIGRATED_REVID=139304928 --- .../devtools/build/lib/exec/ActionInputPrefetcher.java | 7 +++++++ .../devtools/build/lib/runtime/CommandEnvironment.java | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/google/devtools') 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 actionInputPrefetchers = ImmutableList.of(); + private ActionInputPrefetcher actionInputPrefetcher; private Path workingDirectory; private String commandName; @@ -344,8 +345,8 @@ public final class CommandEnvironment { return outputService; } - public ImmutableList 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 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); -- cgit v1.2.3