diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java index bdff840056..bcf26a7c53 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java @@ -76,6 +76,7 @@ import com.google.devtools.build.lib.events.ExtendedEventHandler; import com.google.devtools.build.lib.events.Reporter; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.ProfilerTask; +import com.google.devtools.build.lib.profiler.SilentCloseable; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.io.FileOutErr; import com.google.devtools.build.lib.util.io.OutErr; @@ -546,11 +547,16 @@ public final class SkyframeActionExecutor { long actionStartTime, Iterable<Artifact> resolvedCacheArtifacts, Map<String, String> clientEnv) { - startProfileAction(ProfilerTask.ACTION_CHECK, action); - Token token = - actionCacheChecker.getTokenIfNeedToExecute( - action, resolvedCacheArtifacts, clientEnv, explain ? reporter : null, metadataHandler); - profiler.completeTask(ProfilerTask.ACTION_CHECK); + Token token; + try (SilentCloseable c = profiler.profile(ProfilerTask.ACTION_CHECK, action.describe())) { + token = + actionCacheChecker.getTokenIfNeedToExecute( + action, + resolvedCacheArtifacts, + clientEnv, + explain ? reporter : null, + metadataHandler); + } if (token == null) { boolean eventPosted = false; // Notify BlazeRuntimeStatistics about the action middleman 'execution'. @@ -702,10 +708,6 @@ public final class SkyframeActionExecutor { this.actionInputPrefetcher = actionInputPrefetcher; } - private void startProfileAction(ProfilerTask task, Action action) { - profiler.startTask(task, action.describe()); - } - private class ActionRunner implements Callable<ActionExecutionValue> { private final ExtendedEventHandler eventHandler; private final Action action; @@ -731,8 +733,7 @@ public final class SkyframeActionExecutor { @Override public ActionExecutionValue call() throws ActionExecutionException, InterruptedException { - startProfileAction(ProfilerTask.ACTION, action); - try { + try (SilentCloseable c = profiler.profile(ProfilerTask.ACTION, action.describe())) { if (actionCacheChecker.isActionExecutionProhibited(action)) { // We can't execute an action (e.g. because --check_???_up_to_date option was used). Fail // the build instead. @@ -766,8 +767,6 @@ public final class SkyframeActionExecutor { metadataHandler.getOutputTreeArtifactData(), metadataHandler.getAdditionalOutputData(), actionExecutionContext.getOutputSymlinks()); - } finally { - profiler.completeTask(ProfilerTask.ACTION); } } } @@ -960,12 +959,11 @@ public final class SkyframeActionExecutor { Action action, ActionExecutionContext actionExecutionContext) throws ActionExecutionException, InterruptedException { - startProfileAction(ProfilerTask.ACTION_EXECUTE, action); // ActionExecutionExceptions that occur as the thread is interrupted are // assumed to be a result of that, so we throw InterruptedException // instead. FileOutErr outErrBuffer = actionExecutionContext.getFileOutErr(); - try { + try (SilentCloseable c = profiler.profile(ProfilerTask.ACTION_EXECUTE, action.describe())) { ActionResult actionResult = action.execute(actionExecutionContext); if (actionResult != ActionResult.EMPTY) { eventHandler.post(new ActionResultReceivedEvent(action, actionResult)); @@ -983,8 +981,6 @@ public final class SkyframeActionExecutor { // Defer reporting action success until outputs are checked } catch (ActionExecutionException e) { throw processAndThrow(eventHandler, e, action, outErrBuffer, ErrorTiming.AFTER_EXECUTION); - } finally { - profiler.completeTask(ProfilerTask.ACTION_EXECUTE); } return false; } @@ -999,14 +995,11 @@ public final class SkyframeActionExecutor { Preconditions.checkState(action.inputsDiscovered(), "Action %s successfully executed, but inputs still not known", action); - startProfileAction(ProfilerTask.ACTION_COMPLETE, action); - try { + try (SilentCloseable c = profiler.profile(ProfilerTask.ACTION_COMPLETE, action.describe())) { if (!checkOutputs(action, metadataHandler)) { reportError("not all outputs were created or valid", null, action, outputAlreadyDumped ? null : fileOutErr); } - } finally { - profiler.completeTask(ProfilerTask.ACTION_COMPLETE); } if (outputService != null) { |