diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java index 63ff81af1d72ea..8557bcad155e19 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java @@ -344,8 +344,7 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException { if (enableDiskCache) { var gcIdleTask = - DiskCacheGarbageCollectorIdleTask.create( - remoteOptions, env.getWorkingDirectory(), executorService); + DiskCacheGarbageCollectorIdleTask.create(remoteOptions, env.getWorkingDirectory()); if (gcIdleTask != null) { env.addIdleTask(gcIdleTask); } diff --git a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheGarbageCollectorIdleTask.java b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheGarbageCollectorIdleTask.java index 8f9f68e3805436..ddccdbacd5f120 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheGarbageCollectorIdleTask.java +++ b/src/main/java/com/google/devtools/build/lib/remote/disk/DiskCacheGarbageCollectorIdleTask.java @@ -17,6 +17,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.flogger.GoogleLogger; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.devtools.build.lib.remote.disk.DiskCacheGarbageCollector.CollectionPolicy; import com.google.devtools.build.lib.remote.disk.DiskCacheGarbageCollector.CollectionStats; import com.google.devtools.build.lib.remote.options.RemoteOptions; @@ -26,6 +27,7 @@ import java.time.Duration; import java.util.Optional; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.annotation.Nullable; /** An {@link IdleTask} to run a {@link DiskCacheGarbageCollector}. */ @@ -35,6 +37,10 @@ public final class DiskCacheGarbageCollectorIdleTask implements IdleTask { private final Duration delay; private final DiskCacheGarbageCollector gc; + private static final ExecutorService executorService = + Executors.newCachedThreadPool( + new ThreadFactoryBuilder().setNameFormat("disk-cache-gc-%d").build()); + private DiskCacheGarbageCollectorIdleTask(Duration delay, DiskCacheGarbageCollector gc) { this.delay = delay; this.gc = gc; @@ -50,7 +56,7 @@ private DiskCacheGarbageCollectorIdleTask(Duration delay, DiskCacheGarbageCollec */ @Nullable public static DiskCacheGarbageCollectorIdleTask create( - RemoteOptions remoteOptions, Path workingDirectory, ExecutorService executorService) { + RemoteOptions remoteOptions, Path workingDirectory) { if (remoteOptions.diskCache == null || remoteOptions.diskCache.isEmpty()) { return null; }