aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-02-28 21:29:23 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-02-29 17:39:44 +0000
commit77ad6f6bac968fd35da91fecd8948e0ffed1cb71 (patch)
tree1df97b23dc656935c95c388ddc3576c2d3f9c2da /src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
parentd5093c2e36b7d2850416ae4381ca7b2f8d26ab34 (diff)
Remove incremental heuristic from workers, as it was not really useful.
-- MOS_MIGRATED_REVID=115800229
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java54
1 files changed, 7 insertions, 47 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
index e2b99beee3..3433e98706 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java
@@ -18,8 +18,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
import com.google.common.hash.HashCode;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
@@ -28,7 +26,6 @@ import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputFileCache;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.actions.ActionStatusMessage;
-import com.google.devtools.build.lib.actions.ChangedFilesMessage;
import com.google.devtools.build.lib.actions.ExecException;
import com.google.devtools.build.lib.actions.ExecutionStrategy;
import com.google.devtools.build.lib.actions.Executor;
@@ -37,7 +34,6 @@ import com.google.devtools.build.lib.actions.SpawnActionContext;
import com.google.devtools.build.lib.actions.UserExecException;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.concurrent.ThreadSafety;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy;
@@ -55,16 +51,16 @@ import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* A spawn action context that launches Spawns the first time they are used in a persistent mode and
* then shards work over all the processes.
*/
-@ExecutionStrategy(name = { "worker" }, contextType = SpawnActionContext.class)
-final class WorkerSpawnStrategy implements SpawnActionContext {
- public static final String REASON_HEURISTIC =
- "Not using worker strategy, because incrementalHeuristic says no";
+@ExecutionStrategy(
+ name = {"worker"},
+ contextType = SpawnActionContext.class
+)
+public final class WorkerSpawnStrategy implements SpawnActionContext {
public static final String REASON_NO_FLAGFILE =
"Not using worker strategy, because last argument does not contain a @flagfile";
public static final String REASON_NO_TOOLS =
@@ -72,8 +68,6 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
private final Path execRoot;
private final WorkerPool workers;
- private final IncrementalHeuristic incrementalHeuristic;
- private final StandaloneSpawnStrategy standaloneStrategy;
private final WorkerOptions options;
private final boolean verboseFailures;
private final int maxRetries;
@@ -81,16 +75,12 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
public WorkerSpawnStrategy(
BlazeDirectories blazeDirs,
OptionsClassProvider optionsProvider,
- EventBus eventBus,
WorkerPool workers,
boolean verboseFailures,
int maxRetries) {
Preconditions.checkNotNull(optionsProvider);
this.options = optionsProvider.getOptions(WorkerOptions.class);
- this.incrementalHeuristic = new IncrementalHeuristic(options.workerMaxChangedFiles);
- eventBus.register(incrementalHeuristic);
this.workers = Preconditions.checkNotNull(workers);
- this.standaloneStrategy = new StandaloneSpawnStrategy(blazeDirs.getExecRoot(), verboseFailures);
this.execRoot = blazeDirs.getExecRoot();
this.verboseFailures = verboseFailures;
this.maxRetries = maxRetries;
@@ -101,6 +91,8 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
EventHandler eventHandler = executor.getEventHandler();
+ StandaloneSpawnStrategy standaloneStrategy =
+ Preconditions.checkNotNull(executor.getContext(StandaloneSpawnStrategy.class));
if (executor.reportsSubcommands()) {
executor.reportSubcommand(
@@ -111,14 +103,6 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
spawn.asShellCommand(executor.getExecRoot()));
}
- if (!incrementalHeuristic.shouldUseWorkers()) {
- if (options.workerVerbose) {
- eventHandler.handle(Event.info(REASON_HEURISTIC));
- }
- standaloneStrategy.exec(spawn, actionExecutionContext);
- return;
- }
-
// We assume that the spawn to be executed always gets a @flagfile argument, which contains the
// flags related to the work itself (as opposed to start-up options for the executed tool).
// Thus, we can extract the last element from its args (which will be the @flagfile), expand it
@@ -285,28 +269,4 @@ final class WorkerSpawnStrategy implements SpawnActionContext {
public boolean willExecuteRemotely(boolean remotable) {
return false;
}
-
- /**
- * For installation with remote execution, non-incremental builds may be slowed down by the
- * persistent worker system. To avoid this we only use workers for builds where few files
- * changed.
- */
- @ThreadSafety.ThreadSafe
- private static class IncrementalHeuristic {
- private final AtomicBoolean fewFilesChanged = new AtomicBoolean(false);
- private int limit = 0;
-
- public boolean shouldUseWorkers() {
- return limit == 0 || fewFilesChanged.get();
- }
-
- IncrementalHeuristic(int limit) {
- this.limit = limit;
- }
-
- @Subscribe
- public void changedFiles(ChangedFilesMessage msg) {
- fewFilesChanged.set(msg.getChangedFiles().size() <= limit);
- }
- }
}