aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-06-15 07:19:11 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-15 07:20:37 -0700
commitef5b63ddb4b00a573d3f1c016e508bf3d412b57a (patch)
tree81c760637401c2a5d0b382e4280e69901a51e440 /src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
parentde2623cc0720a3a9646f3dc9844fc2fca3058306 (diff)
Add a bit more profiler coverage
The intent is that the main thread has ~zero gaps in the profile (though there may still be small gaps due to the time between one try block and an immediately subsequent try block). We need to be careful not to wrap markPhase calls (or methods that call markPhase) in try blocks for the profiler - the Profiler requires that all markPhase calls happen at top level, and throws an exception if not. This should not have any performance impact - all of these are once per build, or at most once per module per build, and we don't expect a very large number of modules (and if we see an increasing number, we need to change the module API to not have to call every single module, but only those that are actually interested in certain events, maybe with an EventBus-based setup). PiperOrigin-RevId: 200712677
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
index 14b6c19c01..b217e93e58 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
@@ -21,6 +21,8 @@ import com.google.devtools.build.lib.exec.ExecutionOptions;
import com.google.devtools.build.lib.exec.local.LocalExecutionOptions;
import com.google.devtools.build.lib.pkgcache.LoadingOptions;
import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.profiler.Profiler;
+import com.google.devtools.build.lib.profiler.SilentCloseable;
import com.google.devtools.build.lib.runtime.BlazeCommand;
import com.google.devtools.build.lib.runtime.BlazeCommandResult;
import com.google.devtools.build.lib.runtime.BlazeRuntime;
@@ -65,13 +67,19 @@ public final class BuildCommand implements BlazeCommand {
@Override
public BlazeCommandResult exec(CommandEnvironment env, OptionsProvider options) {
BlazeRuntime runtime = env.getRuntime();
- List<String> targets = ProjectFileSupport.getTargets(runtime.getProjectFileProvider(), options);
+ List<String> targets;
+ try (SilentCloseable closeable = Profiler.instance().profile("ProjectFileSupport.getTargets")) {
+ targets = ProjectFileSupport.getTargets(runtime.getProjectFileProvider(), options);
+ }
- BuildRequest request = BuildRequest.create(
- getClass().getAnnotation(Command.class).name(), options,
- runtime.getStartupOptionsProvider(),
- targets,
- env.getReporter().getOutErr(), env.getCommandId(), env.getCommandStartTime());
+ BuildRequest request;
+ try (SilentCloseable closeable = Profiler.instance().profile("BuildRequest.create")) {
+ request = BuildRequest.create(
+ getClass().getAnnotation(Command.class).name(), options,
+ runtime.getStartupOptionsProvider(),
+ targets,
+ env.getReporter().getOutErr(), env.getCommandId(), env.getCommandStartTime());
+ }
ExitCode exitCode = new BuildTool(env).processRequest(request, null).getExitCondition();
return BlazeCommandResult.exitCode(exitCode);
}