aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2015-10-20 08:57:26 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-10-20 16:38:02 +0000
commitb51461015186b3781205502cf2dc5c04edde686e (patch)
treea9d8f3662f108816dbb24c2d36ae61f4ae07acba /src
parentc585530e1acb3ccf9f249e45663704aaba6f6a51 (diff)
Move commandStartTime from BlazeRuntime to CommandEnvironment.
-- MOS_MIGRATED_REVID=105840775
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java27
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java16
4 files changed, 24 insertions, 26 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index cc3c8046f3..bf018f16b7 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -440,7 +440,7 @@ public class ExecutionTool {
interrupted = true;
throw e;
} finally {
- runtime.recordLastExecutionTime();
+ env.recordLastExecutionTime();
if (request.isRunningInEmacs()) {
request.getOutErr().printErrLn("blaze: Leaving directory `" + getExecRoot() + "/'");
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
index 784b0e1cb8..100a075d92 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -212,9 +212,6 @@ public class BlazeCommandDispatcher {
// anything before this!
long execStartTimeNanos = runtime.getClock().nanoTime();
- // Record the command's starting time for use by the commands themselves.
- runtime.recordCommandStartTime(firstContactTime);
-
// Record the command's starting time again, for use by
// TimestampGranularityMonitor.waitForTimestampGranularity().
// This should be done as close as possible to the start of
@@ -222,6 +219,8 @@ public class BlazeCommandDispatcher {
// rather than in runtime.beforeCommand().
runtime.getTimestampGranularityMonitor().setCommandStartTime();
CommandEnvironment env = runtime.initCommand();
+ // Record the command's starting time for use by the commands themselves.
+ env.recordCommandStartTime(firstContactTime);
if (args.isEmpty()) { // Default to help command if no arguments specified.
args = HELP_COMMAND;
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
index a3074e54f5..ebfd4bf4b3 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
@@ -156,10 +156,10 @@ public final class BlazeRuntime {
private static final Logger LOG = Logger.getLogger(BlazeRuntime.class.getName());
private final BlazeDirectories directories;
- private long commandStartTime;
+ /** The execution time range of the previous build command in this server, if any. */
@Nullable
- private Range<Long> lastExecutionStartFinish = null;
+ private Range<Long> lastExecutionRange = null;
private final SkyframeExecutor skyframeExecutor;
@@ -374,9 +374,9 @@ public final class BlazeRuntime {
}
}
- public void recordLastExecutionTime() {
+ void recordLastExecutionTime(long commandStartTime) {
long currentTimeMillis = clock.currentTimeMillis();
- lastExecutionStartFinish = currentTimeMillis >= commandStartTime
+ lastExecutionRange = currentTimeMillis >= commandStartTime
? Range.closed(commandStartTime, currentTimeMillis)
: null;
}
@@ -386,15 +386,7 @@ public final class BlazeRuntime {
*/
@Nullable
public Range<Long> getLastExecutionTimeRange() {
- return lastExecutionStartFinish;
- }
-
- public void recordCommandStartTime(long commandStartTime) {
- this.commandStartTime = commandStartTime;
- }
-
- public long getCommandStartTime() {
- return commandStartTime;
+ return lastExecutionRange;
}
public String getWorkspaceName() {
@@ -561,16 +553,11 @@ public final class BlazeRuntime {
* Removes in-memory caches.
*/
public void clearCaches() throws IOException {
- clearSkyframeRelevantCaches();
+ skyframeExecutor.resetEvaluator();
actionCache = null;
FileSystemUtils.deleteTree(getCacheDirectory());
}
- /** Removes skyframe cache and other caches that must be kept synchronized with skyframe. */
- private void clearSkyframeRelevantCaches() {
- skyframeExecutor.resetEvaluator();
- }
-
/**
* Returns the TimestampGranularityMonitor. The same monitor object is used
* across multiple Blaze commands, but it doesn't hold any persistent state
@@ -609,8 +596,6 @@ public final class BlazeRuntime {
void beforeCommand(Command command, CommandEnvironment env, OptionsParser optionsParser,
CommonCommandOptions options, long execStartTimeNanos)
throws AbruptExitException {
- commandStartTime -= options.startupTime;
-
env.getEventBus().post(new GotOptionsEvent(startupOptionsProvider,
optionsParser));
env.throwPendingException();
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 732c942a6b..9eda313b68 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
@@ -17,6 +17,7 @@ package com.google.devtools.build.lib.runtime;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Range;
import com.google.common.eventbus.EventBus;
import com.google.devtools.build.lib.actions.PackageRootResolver;
import com.google.devtools.build.lib.actions.cache.ActionCache;
@@ -52,6 +53,8 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.Nullable;
+
/**
* Encapsulates the state needed for a single command. The environment is dropped when the current
* command is done and all corresponding objects are garbage collected.
@@ -68,6 +71,7 @@ public final class CommandEnvironment {
private final LoadingPhaseRunner loadingPhaseRunner;
private final BuildView view;
+ private long commandStartTime;
private String outputFileSystem;
private Path workingDirectory;
@@ -266,8 +270,16 @@ public final class CommandEnvironment {
getWorkingDirectory(), defaultsPackageContents, commandId);
}
+ public void recordLastExecutionTime() {
+ runtime.recordLastExecutionTime(getCommandStartTime());
+ }
+
+ public void recordCommandStartTime(long commandStartTime) {
+ this.commandStartTime = commandStartTime;
+ }
+
public long getCommandStartTime() {
- return runtime.getCommandStartTime();
+ return commandStartTime;
}
void setOutputFileSystem(String outputFileSystem) {
@@ -292,6 +304,8 @@ public final class CommandEnvironment {
void beforeCommand(Command command, OptionsParser optionsParser,
CommonCommandOptions options, long execStartTimeNanos)
throws AbruptExitException {
+ commandStartTime -= options.startupTime;
+
runtime.beforeCommand(command, this, optionsParser, options, execStartTimeNanos);
}
}