Skip to content

Commit

Permalink
Shutdown ByteStream BES artifact uploader threadpool after build.
Browse files Browse the repository at this point in the history
When bazel is configured to upload BES artifacts (eg.
command.profile.gz) using a grpc endpoint, we create a thread pool
dedicated to uploading files for that build. With this change we now
remember to shutdown the threadpool after the build completes.

Fixes #10603.

PiperOrigin-RevId: 305895285
  • Loading branch information
michaeledgar authored and copybara-github committed Apr 10, 2020
1 parent 10e1255 commit d82341d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile;
import com.google.devtools.build.lib.buildeventstream.BuildEventArtifactUploader;
import com.google.devtools.build.lib.buildeventstream.PathConverter;
Expand Down Expand Up @@ -73,7 +74,9 @@ class ByteStreamBuildEventArtifactUploader implements BuildEventArtifactUploader
// Limit the maximum threads number to 1000 (chosen arbitrarily)
this.uploadExecutor =
MoreExecutors.listeningDecorator(
Executors.newFixedThreadPool(Math.min(maxUploadThreads, 1000)));
Executors.newFixedThreadPool(
Math.min(maxUploadThreads, 1000),
new ThreadFactoryBuilder().setNameFormat("bes-artifact-uploader-%d").build()));
this.missingDigestsFinder = missingDigestsFinder;
}

Expand Down Expand Up @@ -250,6 +253,7 @@ public void shutdown() {
return;
}
uploader.release();
uploadExecutor.shutdown();
}

private static class PathConverterImpl implements PathConverter {
Expand Down

0 comments on commit d82341d

Please sign in to comment.