diff options
author | Philipp Wollermann <philwo@google.com> | 2016-08-25 12:59:52 +0000 |
---|---|---|
committer | John Cater <jcater@google.com> | 2016-08-25 20:18:32 +0000 |
commit | 49c20aaccb76769d50f3abb57372b3e9030513a4 (patch) | |
tree | a52677edea168a6b3ab48e8f7e7b58c3a3fab639 /src/main/java/com/google/devtools/build/lib/runtime | |
parent | ed175d6849c46931f4934f8577457ff404b1730f (diff) |
Add a framework for prefetching input files (in case they come from remote file systems).
--
MOS_MIGRATED_REVID=131280794
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java | 16 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java | 15 |
2 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java index 55e7440303..4a487607f3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java @@ -22,6 +22,7 @@ import com.google.devtools.build.lib.analysis.BlazeVersionInfo; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.ServerDirectories; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.exec.ActionInputPrefetcher; import com.google.devtools.build.lib.exec.OutputService; import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.Package; @@ -171,15 +172,24 @@ public abstract class BlazeModule { } /** - * Does any handling of options needed by the command. + * Returns an implementation of {@link ActionInputPrefetcher}. * * <p>This method will be called at the beginning of each command (after #beforeCommand). */ @SuppressWarnings("unused") - public void handleOptions(OptionsProvider optionsProvider) { + public ActionInputPrefetcher getPrefetcher() throws AbruptExitException { + return null; } /** + * Does any handling of options needed by the command. + * + * <p>This method will be called at the beginning of each command (after #beforeCommand). + */ + @SuppressWarnings("unused") + public void handleOptions(OptionsProvider optionsProvider) {} + + /** * Returns extra options this module contributes to a specific command. Note that option * inheritance applies: if this method returns a non-empty list, then the returned options are * added to every command that depends on this command. @@ -187,11 +197,13 @@ public abstract class BlazeModule { * <p>This method may be called at any time, and the returned value may be cached. Implementations * must be thread-safe and never return different lists for the same command object. Typical * implementations look like this: + * * <pre> * return "build".equals(command.name()) * ? ImmutableList.<Class<? extends OptionsBase>>of(MyOptions.class) * : ImmutableList.<Class<? extends OptionsBase>>of(); * </pre> + * * Note that this example adds options to all commands that inherit from the build command. * * <p>This method is also used to generate command-line documentation; in order to avoid 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 c3fec79170..9786f0f1e7 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 @@ -29,10 +29,10 @@ import com.google.devtools.build.lib.analysis.SkyframePackageRootResolver; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection; import com.google.devtools.build.lib.analysis.config.BuildOptions; -import com.google.devtools.build.lib.analysis.config.DefaultsPackage; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.events.Reporter; +import com.google.devtools.build.lib.exec.ActionInputPrefetcher; import com.google.devtools.build.lib.exec.OutputService; import com.google.devtools.build.lib.packages.NoSuchThingException; import com.google.devtools.build.lib.packages.Target; @@ -54,7 +54,6 @@ import com.google.devtools.common.options.OptionPriority; import com.google.devtools.common.options.OptionsParser; import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.OptionsProvider; - import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -86,6 +85,7 @@ public final class CommandEnvironment { private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT; private long commandStartTime; private OutputService outputService; + private ImmutableList<ActionInputPrefetcher> actionInputPrefetchers = ImmutableList.of(); private Path workingDirectory; private AtomicReference<AbruptExitException> pendingException = new AtomicReference<>(); @@ -308,6 +308,10 @@ public final class CommandEnvironment { return outputService; } + public ImmutableList<ActionInputPrefetcher> getActionInputPrefetchers() { + return actionInputPrefetchers; + } + public ActionCache getPersistentActionCache() throws IOException { return workspace.getPersistentActionCache(reporter); } @@ -441,6 +445,7 @@ public final class CommandEnvironment { outputService = null; BlazeModule outputModule = null; + ImmutableList.Builder<ActionInputPrefetcher> prefetchersBuilder = ImmutableList.builder(); for (BlazeModule module : runtime.getBlazeModules()) { OutputService moduleService = module.getOutputService(); if (moduleService != null) { @@ -452,7 +457,13 @@ public final class CommandEnvironment { outputService = moduleService; outputModule = module; } + + ActionInputPrefetcher actionInputPrefetcher = module.getPrefetcher(); + if (actionInputPrefetcher != null) { + prefetchersBuilder.add(actionInputPrefetcher); + } } + actionInputPrefetchers = prefetchersBuilder.build(); SkyframeExecutor skyframeExecutor = getSkyframeExecutor(); skyframeExecutor.setOutputService(outputService); |