Add a hidden flag which allows us to set the size of the legacy globbing thread pool.
--
MOS_MIGRATED_REVID=94236393
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
index 4d7b71f..02c7f03 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
@@ -366,7 +366,7 @@
globalEnv = newGlobalEnvironment();
threadPool = new ThreadPoolExecutor(100, 100, 3L, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
- new ThreadFactoryBuilder().setNameFormat("PackageFactory %d").build());
+ new ThreadFactoryBuilder().setNameFormat("Legacy globber %d").build());
// Do not consume threads when not in use.
threadPool.allowCoreThreadTimeOut(true);
this.environmentExtensions = ImmutableList.copyOf(environmentExtensions);
@@ -388,6 +388,15 @@
}
/**
+ * Sets the max number of threads to use for globbing.
+ */
+ public void setGlobbingThreads(int globbingThreads) {
+ threadPool.setCorePoolSize(globbingThreads);
+ threadPool.setMaximumPoolSize(globbingThreads);
+ }
+
+
+ /**
* Returns the static environment initialized once and shared by all packages
* created by this factory. No updates occur to this environment once created.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
index 6db7cf6..e57fe0d 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
@@ -120,6 +120,12 @@
+ "'private').")
public RuleVisibility defaultVisibility;
+ @Option(name = "legacy_globbing_threads",
+ defaultValue = "100",
+ category = "undocumented",
+ help = "Number of threads to use for glob evaluation.")
+ public int globbingThreads;
+
@Option(name = "min_pkg_count_for_ct_node_eviction",
defaultValue = "3700",
// Why is the default value 3700? As of December 2013, a medium target loads about this many
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index f2ad498..ca12499 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -735,8 +735,8 @@
*/
@VisibleForTesting // productionVisibility = Visibility.PRIVATE
public void preparePackageLoading(PathPackageLocator pkgLocator, RuleVisibility defaultVisibility,
- boolean showLoadingProgress,
- String defaultsPackageContents, UUID commandId) {
+ boolean showLoadingProgress, int globbingThreads,
+ String defaultsPackageContents, UUID commandId) {
Preconditions.checkNotNull(pkgLocator);
setActive(true);
@@ -748,6 +748,7 @@
setPackageLocator(pkgLocator);
syscalls.set(new PerBuildSyscallCache());
+ this.pkgFactory.setGlobbingThreads(globbingThreads);
checkPreprocessorFactory();
emittedEventState.clear();
@@ -1328,7 +1329,7 @@
preparePackageLoading(
createPackageLocator(packageCacheOptions, directories.getWorkspace(), workingDirectory),
packageCacheOptions.defaultVisibility, packageCacheOptions.showLoadingProgress,
- defaultsPackageContents, commandId);
+ packageCacheOptions.globbingThreads, defaultsPackageContents, commandId);
setDeletedPackages(ImmutableSet.copyOf(packageCacheOptions.deletedPackages));
incrementalBuildMonitor = new SkyframeIncrementalBuildMonitor();