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
{{ message }}
Repository navigation
Performance regression for custom autowireBean calls with many properties [SPR-11875] #16494
This used to take 2 microseconds in spring 3.1.4, but now takes 400 microseconds in spring 3.2.0+.
The regression appears to be caused by the fix for #13596, which disables caching of property descriptors in order to fix a memory leak.
What do you think of using org.springframework.util.ConcurrentReferenceHashMap for the property descriptor cache in order to keep the benefit of caching, while still addressing the memory leak reported in #13596?
I eventually resolved this in a different way: We keep using a strong filteredPropertyDescriptorsCache but initialize the allowCaching field with a CacheUtils.isCacheSafe check, along the lines of #16145. This should also be applicable to #13596 where the problem only really came in through generated classes from short-lived child ClassLoaders... and it should re-enable caching for scenarios with regular classes like yours.
Hi Juergen, this fixes the benchmark I provided, but unfortunately in our app many of the classes we autowire are groovy entities and so isCacheSafe() returns false since they are loaded by a (long-lived) GroovyClassLoader. Is there any chance to handle this scenario as well? Thanks.
When beanClass is a Groovy class, beanClass.getClassLoader() will always be a decedent of getBeanClassLoader(). Since ClassUtils.isCacheSafe would only return true if beanClass.getClassLoader() is a parent of getBeanClassLoader(), no Groovy classes will ever be cached.
Juergen Hoeller can you please re-open this issue and perhaps a better solution can be found?
This issue is related to #16483 . That issue references a solution that is used in Grails for optimizing autowire-by-name performance. There are some draw-backs in that solution, but that has suited Grails.
Activity
spring-projects-issues commentedon Jun 27, 2014
Trask Stalnaker commented
I submitted pull request #570 for this. Please let me know if you'd like any changes to it. Thanks.
#570
spring-projects-issues commentedon Jun 29, 2014
Juergen Hoeller commented
I eventually resolved this in a different way: We keep using a strong filteredPropertyDescriptorsCache but initialize the allowCaching field with a CacheUtils.isCacheSafe check, along the lines of #16145. This should also be applicable to #13596 where the problem only really came in through generated classes from short-lived child ClassLoaders... and it should re-enable caching for scenarios with regular classes like yours.
Juergen
spring-projects-issues commentedon Jun 30, 2014
Trask Stalnaker commented
Hi Juergen, this fixes the benchmark I provided, but unfortunately in our app many of the classes we autowire are groovy entities and so isCacheSafe() returns false since they are loaded by a (long-lived) GroovyClassLoader. Is there any chance to handle this scenario as well? Thanks.
spring-projects-issues commentedon Aug 20, 2014
Craig commented
I think Trask Stalnaker is right - this issue still impacts Groovy (particularly Grails).
In AbstractAutowireCapableBeanFactory:
When beanClass is a Groovy class, beanClass.getClassLoader() will always be a decedent of getBeanClassLoader(). Since ClassUtils.isCacheSafe would only return true if beanClass.getClassLoader() is a parent of getBeanClassLoader(), no Groovy classes will ever be cached.
Juergen Hoeller can you please re-open this issue and perhaps a better solution can be found?
spring-projects-issues commentedon Aug 21, 2014
Lari Hotari commented
This issue is related to #16483 . That issue references a solution that is used in Grails for optimizing autowire-by-name performance. There are some draw-backs in that solution, but that has suited Grails.
spring-projects-issues commentedon Sep 3, 2014
Juergen Hoeller commented
I'll leave this issue marked as resolved. Let's rather handle the Groovy case in a dedicated follow-up issue, along the lines of Lari's reference.
Juergen