Skip to content

Commit

Permalink
[7.1.0] Add a profiler span for the findMissingDigests call associate…
Browse files Browse the repository at this point in the history
…d with an upload. (#21552)

PiperOrigin-RevId: 612440278
Change-Id: I9ba6bbb212013596df330d1d3da45e80b4280647
  • Loading branch information
tjgq authored Mar 4, 2024
1 parent 64887f3 commit f50ac05
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SortedSetMultimap;
import com.google.common.collect.TreeMultimap;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.build.lib.actions.ActionExecutionMetadata;
import com.google.devtools.build.lib.actions.ActionUploadFinishedEvent;
import com.google.devtools.build.lib.actions.ActionUploadStartedEvent;
Expand All @@ -53,6 +55,8 @@
import com.google.devtools.build.lib.concurrent.ErrorClassifier;
import com.google.devtools.build.lib.concurrent.NamedForkJoinPool;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.ProfilerTask;
import com.google.devtools.build.lib.remote.common.RemoteActionExecutionContext;
import com.google.devtools.build.lib.remote.common.RemoteCacheClient;
import com.google.devtools.build.lib.remote.common.RemoteCacheClient.ActionKey;
Expand Down Expand Up @@ -94,6 +98,8 @@

/** UploadManifest adds output metadata to a {@link ActionResult}. */
public class UploadManifest {
private static final Profiler profiler = Profiler.instance();

private final DigestUtil digestUtil;
private final RemotePathResolver remotePathResolver;
private final ActionResult.Builder result;
Expand Down Expand Up @@ -679,7 +685,7 @@ public Single<ActionResult> uploadAsync(
ActionExecutionMetadata action = context.getSpawnOwner();

Flowable<RxUtils.TransferResult> bulkTransfers =
toSingle(() -> remoteCache.findMissingDigests(context, digests), directExecutor())
toSingle(() -> findMissingDigests(context, remoteCache, digests), directExecutor())
.doOnSubscribe(d -> reportUploadStarted(reporter, action, Store.CAS, digests))
.doOnError(error -> reportUploadFinished(reporter, action, Store.CAS, digests))
.doOnDispose(() -> reportUploadFinished(reporter, action, Store.CAS, digests))
Expand Down Expand Up @@ -720,4 +726,19 @@ public Single<ActionResult> uploadAsync(

return Completable.concatArray(uploadOutputs, uploadActionResult).toSingleDefault(actionResult);
}

private ListenableFuture<ImmutableSet<Digest>> findMissingDigests(
RemoteActionExecutionContext context, RemoteCache remoteCache, Collection<Digest> digests) {
long startTime = Profiler.nanoTimeMaybe();

var future = remoteCache.findMissingDigests(context, digests);

if (profiler.isActive()) {
future.addListener(
() -> profiler.logSimpleTask(startTime, ProfilerTask.INFO, "findMissingDigests"),
directExecutor());
}

return future;
}
}

0 comments on commit f50ac05

Please sign in to comment.