-
Notifications
You must be signed in to change notification settings - Fork 136
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) #3387
[Performance] Full build takes more time since 2024-09 (type inference) #3387
Conversation
(eclipse-jdt#3384) optimize 3: + never visit the same super type more than once Fixes eclipse-jdt#3327
For a moment I was tricked by the discussion about The requirement put forward by JLS (and thus not subject to our choosing) is similar to What still looks like some combinatorial explosion is in fact a difference between the number of paths vs nodes in the inheritance hierarchy. Viz, the original implementation traversed all paths from Limiting that traversal is what the cache achieves. In contrast to #3333 (comment) no cache of pairs is needed, since Additionally, using I'm still a bit uneasy about using |
FWIW, using the reproducer my poor man's measurements yield:
which is not such a significant gain over results from #3384:
|
@fedejeanne I marked this PR as draft, because I'd like to get feedback on results from #3384 in real life, before stacking more speculative optimization on top of the previous one. I mean we've seen the differences in counts, but not so much in compile time. |
@stephan-herrmann understood, I was about to check the performance gain anyway when I read your comments :-) I am setting up my IDE right now and I will measure performance with #3384 right away. |
|
FTR, even in its current state and with the bad implementations of I just happened to have VisualVM still open so I am adding also a screenshot of the Monitor view. FYI the build took time between ~9:23 to ~9:35 (sorry that I can not be more precise, I wasn't looking at the watch). This is the sample (sampled every 20ms): v20241203-1907 and 3387-Full build (clean workspace).zip And one can see that the hotspots changed:
|
Good, that's what i expected. BTW: you should not trust the Heap/Memory view while you are sampling. Sampling does too much memory overhead. |
I wasn't aware of that, thank you for the tip!
Hm, I didn't know that either. Do you have any hints about what should I look for when debugging these methods? I honestly assumed that these hotspots were "normal" since they were already there in the sampling I did with the good old fast 2024-06 in the original issue (#3327 (comment)) Also, this PR brings down the number of invocations on those 2 methods almost to those of 2024-06 so I don't know how much more there is to improve in there. I can certainly take a look at them after merging this PR though (since this PR improves both of them, I mean). I am always happy to help track and improve performance bottlenecks :-) |
no modification in sight
Please let's be extremely careful about "fixing". The current implementation is necessary for semantic correctness and has served this purpose without any reported issues for 20 years. In fact, scanning the compiler code, there are several locations using TypeBinding as keys in a HashMap. Again with no reported anomalies. Given those precedents, I'll stop worrying at this particular location. If desired, the general topic can be picked up in a follow-up ticket. |
I'm not sure I'm following the reasoning here. Perhaps there's an unintended "not" involved? Or should it read except instead of expect? As you see I'm clueless :) |
So, in the real world case there seems to be something that is not captured in the reproducer. With this gain I agree that there is value in the 3rd level optimization and will merge it, so it will get thorough field testing before release. |
Great, thank you! I'm looking forward to tomorrow's I-BUILD and I will use it ASAP. |
@@ -1277,11 +1283,11 @@ protected List<Pair<TypeBinding>> allSuperPairsWithCommonGenericType(TypeBinding | |||
if (tSuper != null && s.isParameterizedType() && tSuper.isParameterizedType()) { // optimization #1 again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming s.isParameterizedType
is a very cheap operation and findSuperTypeOriginatingFrom
is not:
The lookup of tSuper can be guarded by s.isParameterizedType():
TypeBinding tSuper = s.isParameterizedType() ? t.findSuperTypeOriginatingFrom(s) : null;
if (tSuper != null && tSuper.isParameterizedType()) {
result.add(new Pair<>(s, tSuper));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try this tomorrow and report back. Thank you for the hint!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incredible... I had to sample twice because I couldn't believe my eyes 😄
Thank you, @szarnekow ! --> #3411
optimize 3:
Fixes #3327