aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-06-21 17:58:00 +0200
committerGravatar Philipp Wollermann <philwo@google.com>2017-06-22 11:57:17 +0200
commit716b527266f47f59a2b7fb2e5fc52cb45e1691b1 (patch)
tree34f6dc30ddc1e24ff923bf4341d6c2500c055622
parent33d05f6b551cf2fdb257cb536a5e864d095144a1 (diff)
Only create a single per-build instance of the remote cache / executor
Fixes #3189. Fixes #2823. PiperOrigin-RevId: 159699146
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java51
1 files changed, 27 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
index a8461e4694..f33a28cf5a 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteSpawnStrategy.java
@@ -73,6 +73,9 @@ final class RemoteSpawnStrategy implements SpawnActionContext {
private final ChannelOptions channelOptions;
private final SpawnInputExpander spawnInputExpander = new SpawnInputExpander(/*strict=*/ false);
+ private final RemoteActionCache remoteCache;
+ private final GrpcRemoteExecutor workExecutor;
+
RemoteSpawnStrategy(
Path execRoot,
RemoteOptions remoteOptions,
@@ -97,6 +100,30 @@ final class RemoteSpawnStrategy implements SpawnActionContext {
} else {
platform = null;
}
+ // Initialize remote cache and execution handlers. We use separate handlers for every
+ // action to enable server-side parallelism (need a different gRPC channel per action).
+ if (SimpleBlobStoreFactory.isRemoteCacheOptions(remoteOptions)) {
+ remoteCache = new SimpleBlobStoreActionCache(SimpleBlobStoreFactory.create(remoteOptions));
+ } else if (GrpcActionCache.isRemoteCacheOptions(remoteOptions)) {
+ remoteCache =
+ new GrpcActionCache(
+ RemoteUtils.createChannel(remoteOptions.remoteCache, channelOptions),
+ channelOptions,
+ remoteOptions);
+ } else {
+ remoteCache = null;
+ }
+ // Otherwise remoteCache remains null and remote caching/execution are disabled.
+
+ if (remoteCache != null && GrpcRemoteExecutor.isRemoteExecutionOptions(remoteOptions)) {
+ workExecutor =
+ new GrpcRemoteExecutor(
+ RemoteUtils.createChannel(remoteOptions.remoteExecutor, channelOptions),
+ channelOptions,
+ remoteOptions);
+ } else {
+ workExecutor = null;
+ }
}
private Action buildAction(
@@ -221,30 +248,6 @@ final class RemoteSpawnStrategy implements SpawnActionContext {
String mnemonic = spawn.getMnemonic();
EventHandler eventHandler = actionExecutionContext.getEventHandler();
- RemoteActionCache remoteCache = null;
- GrpcRemoteExecutor workExecutor = null;
- if (spawn.isRemotable()) {
- // Initialize remote cache and execution handlers. We use separate handlers for every
- // action to enable server-side parallelism (need a different gRPC channel per action).
- if (SimpleBlobStoreFactory.isRemoteCacheOptions(remoteOptions)) {
- remoteCache = new SimpleBlobStoreActionCache(SimpleBlobStoreFactory.create(remoteOptions));
- } else if (GrpcActionCache.isRemoteCacheOptions(remoteOptions)) {
- remoteCache =
- new GrpcActionCache(
- RemoteUtils.createChannel(remoteOptions.remoteCache, channelOptions),
- channelOptions,
- remoteOptions);
- }
- // Otherwise remoteCache remains null and remote caching/execution are disabled.
-
- if (remoteCache != null && GrpcRemoteExecutor.isRemoteExecutionOptions(remoteOptions)) {
- workExecutor =
- new GrpcRemoteExecutor(
- RemoteUtils.createChannel(remoteOptions.remoteExecutor, channelOptions),
- channelOptions,
- remoteOptions);
- }
- }
if (!spawn.isRemotable() || remoteCache == null) {
fallbackStrategy.exec(spawn, actionExecutionContext);
return;