diff options
author | nharmata <nharmata@google.com> | 2017-12-21 15:20:49 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-21 15:22:38 -0800 |
commit | 6dcc1393545180d9949d6f797f41a5bfb9758d60 (patch) | |
tree | bfde6c235769a3944765a8435bdc40d02bd2be17 /src/main/java/com/google/devtools/build/lib/skyframe/packages | |
parent | 33657fba55e534cdee6cdf1249689bdf3560347d (diff) |
Some performance improvements to AbstractPackageLoader.
(i) Share the syscall cache used for legacy globbing with the CachingPackageLocator also used by legacy globbing, otherwise it's not very "caching" :(
(ii) Have the concurrency level of the syscall cache used by legacy globbing be set to the number of legacy globbing threads. This actually isn't a huge deal because of (i), since that removes a ton of duplicate cache lookups that would otherwise contend, but there's no reason not to do this.
RELNOTES: None
PiperOrigin-RevId: 179865599
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/packages')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java index 6d465784ae..90fca80f13 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/packages/AbstractPackageLoader.java @@ -72,7 +72,6 @@ import com.google.devtools.build.lib.syntax.SkylarkSemantics; import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; -import com.google.devtools.build.lib.vfs.UnixGlob; import com.google.devtools.build.skyframe.BuildDriver; import com.google.devtools.build.skyframe.Differencer; import com.google.devtools.build.skyframe.ErrorInfo; @@ -121,7 +120,6 @@ public abstract class AbstractPackageLoader implements PackageLoader { protected final ImmutableMap<SkyFunctionName, SkyFunction> extraSkyFunctions; protected final AtomicReference<PathPackageLocator> pkgLocatorRef; protected final ExternalFilesHelper externalFilesHelper; - protected final CachingPackageLocator packageManager; protected final BlazeDirectories directories; private final int legacyGlobbingThreads; private final int skyframeThreads; @@ -235,14 +233,6 @@ public abstract class AbstractPackageLoader implements PackageLoader { pkgLocatorRef, ExternalFileAction.DEPEND_ON_EXTERNAL_PKG_FOR_EXTERNAL_REPO_PATHS, directories); - this.packageManager = new CachingPackageLocator() { - @Override - @Nullable - public Path getBuildFileForPackage(PackageIdentifier packageName) { - return pkgLocatorRef.get().getPackageBuildFileNullable(packageName, - UnixGlob.DEFAULT_SYSCALLS_REF); - } - }; this.preinjectedDiff = makePreinjectedDiff( skylarkSemantics, @@ -355,6 +345,8 @@ public abstract class AbstractPackageLoader implements PackageLoader { CacheBuilder.newBuilder().build(); Cache<PackageIdentifier, CacheEntryWithGlobDeps<AstAfterPreprocessing>> astCache = CacheBuilder.newBuilder().build(); + AtomicReference<PerBuildSyscallCache> syscallCacheRef = new AtomicReference<>( + PerBuildSyscallCache.newBuilder().setConcurrencyLevel(legacyGlobbingThreads).build()); PackageFactory pkgFactory = new PackageFactory( ruleClassProvider, @@ -364,9 +356,16 @@ public abstract class AbstractPackageLoader implements PackageLoader { getName(), Package.Builder.DefaultHelper.INSTANCE); pkgFactory.setGlobbingThreads(legacyGlobbingThreads); - pkgFactory.setSyscalls(new AtomicReference<>(PerBuildSyscallCache.newBuilder().build())); + pkgFactory.setSyscalls(syscallCacheRef); pkgFactory.setMaxDirectoriesToEagerlyVisitInGlobbing( MAX_DIRECTORIES_TO_EAGERLY_VISIT_IN_GLOBBING); + CachingPackageLocator cachingPackageLocator = new CachingPackageLocator() { + @Override + @Nullable + public Path getBuildFileForPackage(PackageIdentifier packageName) { + return pkgLocatorRef.get().getPackageBuildFileNullable(packageName, syscallCacheRef); + } + }; ImmutableMap.Builder<SkyFunctionName, SkyFunction> builder = ImmutableMap.builder(); builder .put(SkyFunctions.PRECOMPUTED, new PrecomputedFunction()) @@ -406,7 +405,7 @@ public abstract class AbstractPackageLoader implements PackageLoader { SkyFunctions.PACKAGE, new PackageFunction( pkgFactory, - packageManager, + cachingPackageLocator, /*showLoadingProgress=*/ new AtomicBoolean(false), packageFunctionCache, astCache, |