Repository navigation
ADFA-6854: Share one javac package map per JAR across file managers - #2229
Draft
itsaky-adfa wants to merge 4 commits into
Draft
itsaky-adfa wants to merge 4 commits into
itsaky-adfa wants to merge 4 commits into
Conversation
|
To enable Code Reviewer, link your GitHub account to your Atlassian account. This is a one-time task that takes less than a minute. Once your account is linked, resubmit the pull request to trigger a code review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft, part 2 of 4 of the ADFA-6854 stack. Do not merge yet: see "Open items" in the top PR.
Stack (bottom to top):
JarListing: one packed index per JAR for zipfs2 and javacJarListing(needs a kt-android release)What
CachedJarFileSystem.packageIndex()builds a JAR'sRelativeDirectory -> Pathpackage map once. The map is read-only and safe for concurrent first access.JarPackageProviderImpl.getPackagesreturns that map, so every javacArchiveContainershares it instead of walking the archive itself (JavacFileManager.java:629-654).SourceFileManagernow registersJarPackageProviderin the context of its delegate file manager. Without it, javac falls back to an empty map and a full walk per container (JavacFileManager.java:183-186). This was why the Java LSP's file managers did not get the shared map in the first on-device run.JarFsClasspathReader(boot classpath) no longer builds the map as a side effect of its walk. It reads the shared index and lists each package directory once.Why
The ticket measured 37.1 MB of per-file-manager package maps, because
CachedJarFileSystem.packageswas filled only for boot JARs. Every file manager walked every JAR and kept its own map.Measured
OnePlus Pad 2, cold open of CoGo at
stageffaa75be84, heap dump after open, javac structures reachable fromJavacFileManager:stageSourceFileManagerfix (a71e6da99c)3254dcc1db)With PR 3 the shared map is a lazy view over the JAR's listing, so the shared part adds no per-package objects.
The remaining 26.6 MB is not the package map. It is javac's own per-manager index,
pathsAndContainersByLocationAndRelativeDirectory, which every one of the 98SourceFileManagers in the dump builds for itself (the ticket counted 91 managers). Reducing it needs either a change to that index inside javac or fewer file managers. It is tracked as an open item in the top PR.Tests
CachedJarFileSystemPackageIndexTest: equality with javac's own walk, one instance across callers, 16 concurrent first callers, non-identifier directories skipped.SourceFileManagerSharedPackagesTest: the archive containers of two separate file managers share the JAR's package map, and classes are still listed through it.JarFsClasspathReaderListClassesTest: same classes listed as before.:lsp:java:testV7DebugUnitTest:JavaCompilerProviderTest > test module specific compilersfails, and the task hits Gradle's 10-minute timeout. Both also happen onstagewithout this stack.