From 4d248eabb49d954112468d33b1445c203368245d Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Wed, 13 Dec 2023 00:05:05 -0800 Subject: [PATCH] Add profiling to `remoteActionBuildingSemaphore.acquire()` Without this there can be large gaps in the profile when using remote execution that are hard to reason about. Closes #20474. PiperOrigin-RevId: 590475989 Change-Id: Ic6e042c36f85e8098a468c73c62bd45cc367423e --- .../build/lib/remote/RemoteExecutionService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java index 47434f2d1f944f..94e6307ad1529f 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionService.java @@ -517,7 +517,10 @@ private ToolSignature getToolSignature(Spawn spawn, SpawnExecutionContext contex /** Creates a new {@link RemoteAction} instance from spawn. */ public RemoteAction buildRemoteAction(Spawn spawn, SpawnExecutionContext context) throws IOException, ExecException, ForbiddenActionInputException, InterruptedException { - remoteActionBuildingSemaphore.acquire(); + try (SilentCloseable c = + Profiler.instance().profile(ProfilerTask.REMOTE_SETUP, "acquiring semaphore")) { + remoteActionBuildingSemaphore.acquire(); + } try { ToolSignature toolSignature = getToolSignature(spawn, context); final MerkleTree merkleTree = buildInputMerkleTree(spawn, context, toolSignature); @@ -1460,7 +1463,10 @@ public void uploadInputsIfNotPresent(RemoteAction action, boolean force) // concurrency. This prevents memory exhaustion. We assume that // ensureInputsPresent() provides enough parallelism to saturate the // network connection. - remoteActionBuildingSemaphore.acquire(); + try (SilentCloseable c = + Profiler.instance().profile(ProfilerTask.UPLOAD_TIME, "acquiring semaphore")) { + remoteActionBuildingSemaphore.acquire(); + } try { MerkleTree merkleTree = action.getMerkleTree(); if (merkleTree == null) {