Skip to content

Commit 8747554

Browse files
coeuvretraversaro
authored andcommitted
Add profile spans for the network handshake inside RemoteModule#beforeCommand.
PiperOrigin-RevId: 538498468 Change-Id: I88cb9114bb370f42ecdeaac5b592b3a4e9ab4f08
1 parent 0da8c07 commit 8747554

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import com.google.devtools.build.lib.exec.ExecutorBuilder;
6060
import com.google.devtools.build.lib.exec.ModuleActionContextRegistry;
6161
import com.google.devtools.build.lib.exec.SpawnStrategyRegistry;
62+
import com.google.devtools.build.lib.profiler.Profiler;
6263
import com.google.devtools.build.lib.remote.RemoteServerCapabilities.ServerCapabilitiesRequirement;
6364
import com.google.devtools.build.lib.remote.circuitbreaker.CircuitBreakerFactory;
6465
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
@@ -443,45 +444,49 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
443444
}
444445

445446
if (enableRemoteExecution) {
446-
ImmutableList.Builder<ClientInterceptor> interceptors = ImmutableList.builder();
447-
interceptors.add(TracingMetadataUtils.newExecHeadersInterceptor(remoteOptions));
448-
if (loggingInterceptor != null) {
449-
interceptors.add(loggingInterceptor);
450-
}
451-
execChannel =
452-
new ReferenceCountedChannel(
453-
new GoogleChannelConnectionFactory(
454-
channelFactory,
455-
remoteOptions.remoteExecutor,
456-
remoteOptions.remoteProxy,
457-
authAndTlsOptions,
458-
interceptors.build(),
459-
maxConcurrencyPerConnection),
460-
maxConnections);
461-
462-
// Create a separate channel if --remote_executor and --remote_cache point to different
463-
// endpoints.
464-
if (remoteOptions.remoteCache.equals(remoteOptions.remoteExecutor)) {
465-
cacheChannel = execChannel.retain();
447+
try (var s = Profiler.instance().profile("init exec channel")) {
448+
ImmutableList.Builder<ClientInterceptor> interceptors = ImmutableList.builder();
449+
interceptors.add(TracingMetadataUtils.newExecHeadersInterceptor(remoteOptions));
450+
if (loggingInterceptor != null) {
451+
interceptors.add(loggingInterceptor);
452+
}
453+
execChannel =
454+
new ReferenceCountedChannel(
455+
new GoogleChannelConnectionFactory(
456+
channelFactory,
457+
remoteOptions.remoteExecutor,
458+
remoteOptions.remoteProxy,
459+
authAndTlsOptions,
460+
interceptors.build(),
461+
maxConcurrencyPerConnection),
462+
maxConnections);
463+
464+
// Create a separate channel if --remote_executor and --remote_cache point to different
465+
// endpoints.
466+
if (remoteOptions.remoteCache.equals(remoteOptions.remoteExecutor)) {
467+
cacheChannel = execChannel.retain();
468+
}
466469
}
467470
}
468471

469472
if (cacheChannel == null) {
470-
ImmutableList.Builder<ClientInterceptor> interceptors = ImmutableList.builder();
471-
interceptors.add(TracingMetadataUtils.newCacheHeadersInterceptor(remoteOptions));
472-
if (loggingInterceptor != null) {
473-
interceptors.add(loggingInterceptor);
473+
try (var s = Profiler.instance().profile("init cache channel")) {
474+
ImmutableList.Builder<ClientInterceptor> interceptors = ImmutableList.builder();
475+
interceptors.add(TracingMetadataUtils.newCacheHeadersInterceptor(remoteOptions));
476+
if (loggingInterceptor != null) {
477+
interceptors.add(loggingInterceptor);
478+
}
479+
cacheChannel =
480+
new ReferenceCountedChannel(
481+
new GoogleChannelConnectionFactory(
482+
channelFactory,
483+
remoteOptions.remoteCache,
484+
remoteOptions.remoteProxy,
485+
authAndTlsOptions,
486+
interceptors.build(),
487+
maxConcurrencyPerConnection),
488+
maxConnections);
474489
}
475-
cacheChannel =
476-
new ReferenceCountedChannel(
477-
new GoogleChannelConnectionFactory(
478-
channelFactory,
479-
remoteOptions.remoteCache,
480-
remoteOptions.remoteProxy,
481-
authAndTlsOptions,
482-
interceptors.build(),
483-
maxConcurrencyPerConnection),
484-
maxConnections);
485490
}
486491

487492
if (enableRemoteDownloader) {
@@ -526,7 +531,7 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
526531
// capabilities respectively.
527532
ServerCapabilities executionCapabilities = null;
528533
ServerCapabilities cacheCapabilities = null;
529-
try {
534+
try (var s = Profiler.instance().profile("check server capabilities")) {
530535
if (execChannel != null) {
531536
if (cacheChannel != execChannel) {
532537
executionCapabilities =

0 commit comments

Comments
 (0)