-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.eclipse.jdt.internal.core.builder.ClasspathJar.knownPackageNames slow and not threadsafe #3250
Comments
I assume replacing SimpleSet with HashSet would be right thing to do, also in terms of performance. |
Sounds plausible, it would be terrific if could be confirmed and closed. Good luck. |
performance sidenode: that org.eclipse.jdt.internal.core.builder.NameEnvironment.findClass(String, char[], LookupStrategy, String) searches in all libraries ("relevantLocations") with a loop while intuitively it would be clear in which library to search by package name. Also it feels contraproductive in LookupEnvironment.createPlainPackage(char[][]) to search for obviously not existing packages like "com" (which is the first part of the fqn) (just to make sure there is no collision with a class named like a package?) |
Not sure how? Library names not always match package names, or usually they don't match.
Why that? "com" is valid package name. Unusual to place classes there, yes, but you never know what crazy code users will use or write :) |
the libraries don't change frequently so there could be something like a The class that is search is for example |
So you are speaking of caching, not of changing the strategy to search in the first place? In that way, what you call "intuitively" (which is definitely non-compiler-like) should in fact be: the name environment could remember ... similar to how LookupEnvironment puts TheNotFoundPackage into its caches? |
Yea should be possible either somehow cache the result or precompute such a map whenever the libs change. Here is an example Stacktrace with manual added parameters in front - which feel wrong:
|
What exactly feels wrong, and why? |
I wonder why you keep speaking of lib changes? Libraries typically don't change while a build is running. Are you considering to persist cached information? |
Even better, then just map all packages to libs once per build instead of per cu :-)
It does not feel right to first search for a non-existing class |
No. In the search scope you may have both at same time, multiple times :-) |
Keep in mind that The compiler has quite complex code to analyze qualified names. It's a pity that the name environment cannot use the information cached in LookupEnvironment. Another complication: when one request for potential class |
* use Set<String> * cache a unmodifiable copy * simplify PackageCacheEntry to record * add missing final/volatile modifiers * remove ClasspathJrt.PackageCache (only module names had been used) * don't calculate unused location of module.info * remove closeZipFileAtEnd (was always true when zipfile!=null) eclipse-jdt#3250
* use Set<String> * cache a unmodifiable copy * simplify PackageCacheEntry to record * add missing final/volatile modifiers * remove ClasspathJrt.PackageCache (only module names had been used) * don't calculate unused location of module.info * remove closeZipFileAtEnd (was always true when zipfile!=null) eclipse-jdt#3250
* use Set<String> * cache a unmodifiable copy * simplify PackageCacheEntry to record * add missing final/volatile modifiers * remove ClasspathJrt.PackageCache (only module names had been used) * don't calculate unused location of module.info * remove closeZipFileAtEnd (was always true when zipfile!=null) #3250
ClasspathJar.isPackage(String, String) seems to be used from multiple threads, uses ClasspathJar.knownPackageNames, which does not seem to have any synchronization. While ClasspathJar.findPackageSet() tries to be thread safe it returns a SimpleSet which itself has no threading guaranties.
Maybe that relates to #2877 ?
It might also be more readable if the SimpleSet would know to include only
<String>
in this usage. Maybe just use a some standard java Set.I only stumbled across it when i saw ClasspathJar.isPackage() was reported to be the hotspot of hibernate annotation processing on a big project:
that feels inappropriate.
The text was updated successfully, but these errors were encountered: