You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #16486, CachedIntrospectionResults was changed to use a ConcurrentHashMap for typeDescriptorCache. This change is definitely positive and had a significant improvement to performance in my testing.
I think that using putIfAbsent (instead of just put) would be a further improvement in the addTypeDescriptor method. Changing:
Oops, I just noticed based on your pull request that my commit from a few minutes ago only works on JDK 8... where putIfAbsent has been added as a default method to the Map interface itself. Fixing this now towards ConcurrentMap declarations that work on JDK 6 and 7 as well.
As for using the pre-cached values as returned from putIfAbsent, this doesn't seem to make much difference, since the values are going to be equivalent anyway?
I figured that using the pre-cached values reduces the total number of objects in memory (by just a tiny amount) so it was worth doing. It doesn't seem like it should really matter, but I figured, why not do it as best as I could think of. :-)
Alright, along with fixing the ConcurrentMap declarations, I've changed the code to reuse existing cached values where possible (including TypeDescriptors in BeanWrapperImpl).
Craig opened SPR-12102 and commented
In #16486, CachedIntrospectionResults was changed to use a ConcurrentHashMap for typeDescriptorCache. This change is definitely positive and had a significant improvement to performance in my testing.
I think that using putIfAbsent (instead of just put) would be a further improvement in the addTypeDescriptor method. Changing:
to
should result in less writes to volatile variables improve performance of getTypeDescriptor.
Changing the other ConcurrentHashMap (strongClassCache and softClassCache) put()'s to putIfAbsent()'s would probably also be beneficial.
Affects: 4.1 RC2
Issue Links:
Referenced from: commits af6ef5f, 781a6d2
The text was updated successfully, but these errors were encountered: