-
Notifications
You must be signed in to change notification settings - Fork 915
Replace WeakSet usage with JDK equivalent and deprecate class. #8411
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
Conversation
f0bb224 to
146e3b2
Compare
146e3b2 to
80e3966
Compare
|
trying to figure out what the purpose of the ElementHandle deduplication code is. Its not for instance comparison reasons, since $a == $b
:: $a instanceof org.netbeans.api.java.source.ElementHandle
&& $b instanceof org.netbeans.api.java.source.ElementHandle
&& !isNullLiteral($b)
=>
$a.equals($b)
;;
$a != $b
:: $a instanceof org.netbeans.api.java.source.ElementHandle
&& $b instanceof org.netbeans.api.java.source.ElementHandle
&& !isNullLiteral($b)
=>
!$a.equals($b)
;;produced no relevant hits. Here is the original commit emilianbold/netbeans-releases@3dab461 referencing https://bz.apache.org/netbeans/show_bug.cgi?id=197743 https://bz.apache.org/netbeans/show_bug.cgi?id=197743#c2 indicates it was one of the changes to attempt to reduce memory consumption in large files. Will check if this deduplication cache could be removed again. A new handle has to be created first before checking if it is already there (no construction overhead reduction) and secondly the Object itself is just two constants: |
80e3966 to
6ce9029
Compare
|
removed the this spawned two more PRs to tackle performance problems I noticed while playing with that test project:
filed issue for third scaling problem: |
6ce9029 to
d1add04
Compare
|
planning to get this PR in as soon as possible after RC3 |
|
I am running this together with some of the performance enhancement PRs and everything is working fine. I was mostly worried about the removal of the So my current thinking is that we can indeed remove the deduplication (see second commit with the "problem cases" edit: will refresh this PR with a rebase - no other changes |
lkishalmi
left a comment
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.
Let's go for this!
neilcsmith-net
left a comment
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.
Looks sane, not tested.
Had a concern at first about the explicit sizing of the WeakHashMaps but see that WeakSet used the same load factor logic. I'm curious how many of those capacities are correct, but better to merge matching existing behaviour.
|
those sizing values are a "false friend", somewhat similar to |
|
Yes, I know - that's what caught my eye looking at this. Funnily enough your blog post was one of the first things that popped up when I searched for the JDK 19+ methods to check the difference in behaviour! 😄 |
- WeakSet is now deprecated for removal - usage can be replaced with WeakHashMap and Collections.newSetFromMap()
- web logic config factory doesn't seem to need caching, it is only called from one place, and that object is cached too - ElementHandle used the WeakSet to deduplicate instances (original reason were memory concerns), testing showed that this had little impact and can be likely also removed
|
thanks for the review! |
Instead of updating
WeakSet(#8380) we deprecate it for removal and replace all usage.Once the build starts failing we can still decide what to do with it.
WeakSetis now deprecated for removalWeakHashMapandCollections.newSetFromMap()part of #8257
have to take a good look at all usages which used
putifAbsent, some might need tweaksElementHandlededuplicaiton mechanism can be replicated using a WeakHashMap and storing the handle as key and as WeakReference-wrapped value. This way the old element can be extracted if there is a match, while allowing the map to shring if the handles aren't used anymore. Not 100% sure yet what overhead this is supposed to avoid though since theElementHandleis created in all paths, but an old handle is returned on hit while discarding the new one.WebLogicConfigurationremoved the cache since it was redundant. The caller is cached. Someone liked caches.main difference is that all calls to
WeakSet#addwere implemented viaputIfAbsent. This is not the case in WeakHashMap, however, during the typical use case (e.g listener storage) this should not make a difference.