diff options
Diffstat (limited to 'src/main/java/com')
3 files changed, 13 insertions, 14 deletions
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 dae2f597f8..5c55d8309f 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 @@ -437,12 +437,20 @@ public class BlazeCommandDispatcher { } } + // Profiler setup and shutdown _must_ always happen in pairs. Shutdown is currently performed + // in the finally block (in the afterCommand call), so this call must not be moved outside + // this try-finally block. + env.getRuntime().initProfiler( + env.getReporter(), + env.getBlazeWorkspace(), + commonOptions, + env.getCommandId(), + execStartTimeNanos); try { // Notify the BlazeRuntime, so it can do some initial setup. env.beforeCommand( options, commonOptions, - execStartTimeNanos, waitTimeInMs, invocationPolicy); } catch (AbruptExitException e) { 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 b2c9607920..12276f4547 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 @@ -260,10 +260,8 @@ public final class BlazeRuntime { return moduleInvocationPolicy; } - /** - * Conditionally enable profiling. - */ - private void initProfiler( + /** Configure profiling based on the provided options. */ + void initProfiler( EventHandler eventHandler, BlazeWorkspace workspace, CommonCommandOptions options, @@ -439,14 +437,8 @@ public final class BlazeRuntime { * @param options The CommonCommandOptions used by every command. * @throws AbruptExitException if this command is unsuitable to be run as specified */ - void beforeCommand(CommandEnvironment env, CommonCommandOptions options, long execStartTimeNanos) + void beforeCommand(CommandEnvironment env, CommonCommandOptions options) throws AbruptExitException { - initProfiler( - env.getReporter(), - env.getBlazeWorkspace(), - options, - env.getCommandId(), - execStartTimeNanos); if (options.memoryProfilePath != null) { Path memoryProfilePath = env.getWorkingDirectory().getRelative(options.memoryProfilePath); MemoryProfiler.instance() 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 fae1810fe3..34593b6662 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 @@ -566,7 +566,6 @@ public final class CommandEnvironment { void beforeCommand( OptionsProvider options, CommonCommandOptions commonOptions, - long execStartTimeNanos, long waitTimeInMs, InvocationPolicy invocationPolicy) throws AbruptExitException { @@ -622,7 +621,7 @@ public final class CommandEnvironment { reporter); // Start the performance and memory profilers. - runtime.beforeCommand(this, commonOptions, execStartTimeNanos); + runtime.beforeCommand(this, commonOptions); eventBus.post(new CommandStartEvent( command.name(), getCommandId(), getClientEnv(), workingDirectory, getDirectories(), |