-
Notifications
You must be signed in to change notification settings - Fork 133
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
[Performance] Full build takes more time since 2024-09 (type inference) #3327
[Performance] Full build takes more time since 2024-09 (type inference) #3327
Comments
my bet it's caused by changes in org.eclipse.jdt.internal.compiler.lookup.BoundSet.deriveTypeArgumentConstraints(TypeBound, TypeBound, InferenceContext18): |
@fedejeanne it may help if you share a script that generates an artificial project with such a complex type hierarchy |
Have you tried with https://github.com/iloveeclipse/java-project-generator? The code generates large type hierarchies by default. |
I'm on it. It's kind of hacky but I managed to revert the changes of cc0e66e in the I-BUILD 20241118-1800 and I am compiling with it right now.
I am going to take a look at the generator (#3327 (comment)) and see if I can provide a large project to reproduce the issue. |
I managed to revert the commit and sample again and the build time was reduced back to (almost) that of 2024-06: ~12 m. 20241118-1800-no-cc0e66e-Build all (clean workspace).zip This confirms your theory @jukzi : cc0e66e introduced the performance degradation. EDIT: the build time of 2024-06 was ~10 m so the performance of 20241118-1800-no-cc0e66e is not quite the same but it is safe to assume that cc0e66e introduced most of the performance degradation. |
@stephan-herrmann please take a look. |
@stephan-herrmann : could you please look at this ticket? Unfortunately no reproducer yet, but might be you know where the bottleneck could be. PS |
Our product is quite big: ~2000 projects in the workspace and a few 100's of MB in source code. It has also generated code and meta-models (similar to EMF but a bit more complex). So yes: there is multi-inheritance and probably a lot more complex stuff in there. If there's anything I can debug in order to check for such special cases that might be interesting to analyze this issue, please let me know. |
I happened to see your requests, but I don't currently have the time for anything that could help 4.34. I don't think the bug fixed by cc0e66e has a "simpler" solution. Java is a complex beast. So I see these options:
Anything along the lines of (2) probably needs quite a bit of experimentation to strike a good balance: don't penalize use cases that are not affected by the current issue, don't waste memory by speculative optimization etc. pp. => Sounds like a task for the next release cycle. |
@stephan-herrmann could you handcraft an idea of an simple reproducer that can trigger this behavior?
sounds fair! |
cc0e66e has some test cases that trigger the code in question. The original issue #2413 also discusses when/why/where we need to investigate all possible pairs of super types. Also interesting: in #2413 (comment) a variant is shown, that does not require that fix. Read: it is a matter of heavy type inference combined with wildcards in certain positions. |
some ideas: As far as i understand deriveTypeArgumentConstraints() calls allSuperPairsWithCommonGenericType() to return a Set which can be significant long and can contain duplicates. After that the only caller incorporate() may skip most of the result because it is only interested if any ConstraintTypeFormula that yields !reduceOneConstraint(). i.e. most of the computation could have be totally unnecessary. Instead one could implement a function that eager returns false while iterating the result elements without ever calculating any Set of |
Hmm. I've added one extra generic argument in my code generator to the already generified generated code and see now that master builds 20% slower as reverted commit (was almost same before). Not sure if the revert was correct, as had few merge issues which I believed to fix right, but I've run out of time. Also it is not 2x slower, but of course my dummy code is generated in a very simple way. Still 20% seem to be relevant. All what I did was to change Update: I've also added more deep type hierarchies, so A extends B extends C etc is deeper as before (not 5 levels but ~1000). |
I tried some of the ideas by @jukzi (#3327 (comment)) but the performance didn't really improve. The best improvement I got was from ~30 min to ~29 min. What I tried
I'll keep looking into it. Any hints/ideas are appreciated :) |
such may be caused by by insufficient equals() or hashCode() of the key, so that duplicates are not really found. |
I tried some variations of In any case, the memory consumption was slightly reduced but the performance didn't improve. Thank you for the hint though :-) |
…pse-jdt#3227 This simple approach was faster than the new one but it didn't cover some very specific use cases, which is why the newer and more complex (slower) approach was introduced. This commit brings back the older, simpler, approach and falls back to the newer, more expensive, approach only when necessary. Fixes eclipse-jdt#3327
…pse-jdt#3227 This simple approach was faster than the new one but it didn't cover some very specific use cases, which is why the newer and more complex (slower) approach was introduced. This commit brings back the older, simpler, approach and falls back to the newer, more expensive, approach only when necessary. Reduce the visibility of BoundSet::allSuperPairsWithCommonGenericType from protected to private too. Fixes eclipse-jdt#3327
…pse-jdt#3227 This simple approach was faster than the new one but it didn't cover some very specific use cases, which is why the newer and more complex (slower) approach was introduced. This commit brings back the older, simpler, approach and falls back to the newer, more expensive, approach only when necessary. Reduce the visibility of BoundSet::allSuperPairsWithCommonGenericType from protected to private too. Fixes eclipse-jdt#3327
…pse-jdt#3227 This simple approach was faster than the new one but it didn't cover some very specific use cases, which is why the newer and more complex (slower) approach was introduced. This commit brings back the older, simpler, approach and falls back to the newer, more expensive, approach only when necessary. Reduce the visibility of BoundSet::allSuperPairsWithCommonGenericType from protected to private too. Fixes eclipse-jdt#3327
…pse-jdt#3227 This simple approach was faster than the new one but it didn't cover some very specific use cases, which is why the newer and more complex (slower) approach was introduced. This commit brings back the older, simpler, approach and falls back to the newer, more expensive, approach only when necessary. Reduce the visibility of BoundSet::allSuperPairsWithCommonGenericType from protected to private too. Fixes eclipse-jdt#3327
optimize 1: + don't record pairs without any type arguments optimize 2: + stop traversal when both types are the same Fixes eclipse-jdt#3327
strengthen optimization 1: + record only pairs where both types are parameterized Fixes eclipse-jdt#3327
reproducer boils down to:
|
(eclipse-jdt#3384) optimize 3: + never visit the same super type more than once Fixes eclipse-jdt#3327
Discussed in #3305
Originally posted by fedejeanne November 13, 2024
Hi,
I've been looking into some performance issues that started with 2024-09, specifically the time it takes to perform a full build. Interestingly enough, the time it takes to do a clean all also increased in 2024-09 but the biggest increase happened in the build phase.
samples.zip
The part that caught my eye was the increase in amount of calls (Hits) and therefore the Self Time (CPU) for the method(s)
org.eclipse.jdt.internal.compiler.lookup.TypeBinding.findSuperTypeOriginatingFrom(...)
(there are 2 flavors of this method).2024-06
2024-09
Question 1
Question 2
I ask because I noticed that many of the calls are "repeated" i.e. the input parameters are the same so a cache would be a trivial optimization.
The text was updated successfully, but these errors were encountered: