Skip to content

Commit

Permalink
Move closure of profiler before BlazeRuntime#afterCommand() is ca…
Browse files Browse the repository at this point in the history
…lled

PiperOrigin-RevId: 679269384
Change-Id: I93bbca2126972f3e1fef0addba3575f1fc872161
  • Loading branch information
yuyue730 authored and copybara-github committed Sep 26, 2024
1 parent 108f117 commit 355b408
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,6 @@ private BlazeCommandResult execExclusively(
result = BlazeCommandResult.createShutdown(crash);
return result;
} finally {
if (needToCallAfterCommand) {
BlazeCommandResult newResult = runtime.afterCommand(false, env, result);
if (!newResult.equals(result)) {
logger.atWarning().log("afterCommand yielded different result: %s %s", result, newResult);
}
}

try {
Profiler.instance().stop();
if (profilerStartedEvent.getProfile() instanceof LocalInstrumentationOutput profile) {
Expand All @@ -739,8 +732,15 @@ private BlazeCommandResult execExclusively(
env.getReporter()
.handle(Event.error("Error while writing profile file: " + e.getMessage()));
}

Profiler.instance().clear();

if (needToCallAfterCommand) {
BlazeCommandResult newResult = runtime.afterCommand(false, env, result);
if (!newResult.equals(result)) {
logger.atWarning().log("afterCommand yielded different result: %s %s", result, newResult);
}
}

MemoryProfiler.instance().stop();

// Swallow IOException, as we are already in a finally clause
Expand Down

0 comments on commit 355b408

Please sign in to comment.