Skip to content

Commit

Permalink
Improve profiling of times spent in client.
Browse files Browse the repository at this point in the history
- Make launch time an event with duration.
- Add extraction time to the profile.
- Add wait times (both in client and server) to the profile.

RELNOTES: None
PiperOrigin-RevId: 215369415
  • Loading branch information
meisterT authored and Copybara-Service committed Oct 2, 2018
1 parent 5f312dd commit c070221
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ private BlazeCommandResult execExclusively(
// the afterCommand call in the finally block below.
Path profilePath =
runtime.initProfiler(
storedEventHandler, workspace, commonOptions, env.getCommandId(), execStartTimeNanos);
storedEventHandler,
workspace,
commonOptions,
env.getCommandId(),
execStartTimeNanos,
waitTimeInMs);
if (commonOptions.postProfileStartedEvent) {
storedEventHandler.post(new ProfilerStartedEvent(profilePath));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ Path initProfiler(
BlazeWorkspace workspace,
CommonCommandOptions options,
UUID buildID,
long execStartTimeNanos) {
long execStartTimeNanos,
long waitTimeInMs) {
OutputStream out = null;
boolean recordFullProfilerData = false;
ProfiledTaskKinds profiledTasks = ProfiledTaskKinds.NONE;
Expand Down Expand Up @@ -324,11 +325,34 @@ Path initProfiler(
// the launcher. We're setting the INIT phase marker so that it follows immediately the
// LAUNCH phase.
long startupTimeNanos = options.startupTime * 1000000L;
long waitTimeNanos = waitTimeInMs * 1000000L;
long clientStartTimeNanos = execStartTimeNanos - startupTimeNanos - waitTimeNanos;
profiler.logSimpleTaskDuration(
execStartTimeNanos - startupTimeNanos,
Duration.ZERO,
clientStartTimeNanos,
Duration.ofNanos(startupTimeNanos),
ProfilerTask.PHASE,
ProfilePhase.LAUNCH.description);
if (options.extractDataTime > 0) {
profiler.logSimpleTaskDuration(
clientStartTimeNanos,
Duration.ofMillis(options.extractDataTime),
ProfilerTask.PHASE,
"Extracting Bazel binary");
}
if (options.waitTime > 0) {
profiler.logSimpleTaskDuration(
clientStartTimeNanos,
Duration.ofMillis(options.waitTime),
ProfilerTask.PHASE,
"Blocking on busy Bazel server (in client)");
}
if (waitTimeInMs > 0) {
profiler.logSimpleTaskDuration(
clientStartTimeNanos + startupTimeNanos,
Duration.ofMillis(waitTimeInMs),
ProfilerTask.PHASE,
"Blocking on busy Bazel server (in server)");
}
profiler.logSimpleTaskDuration(
execStartTimeNanos, Duration.ZERO, ProfilerTask.PHASE, ProfilePhase.INIT.description);
}
Expand Down

0 comments on commit c070221

Please sign in to comment.