Shutdown ByteStream BES artifact uploader threadpool after build.
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
@@ -24,6 +24,7 @@ import com.google.common.util.concurrent.Futures;
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;
@@ -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;
}
@@ -250,6 +253,7 @@ class ByteStreamBuildEventArtifactUploader implements BuildEventArtifactUploader
return;
}
uploader.release();
+ uploadExecutor.shutdown();
}
private static class PathConverterImpl implements PathConverter {
