Description
Vladimir Gordiychuk opened SPR-13655 and commented
Current implementation of getCacheKey uses string concatenation: https://github.com/spring-projects/spring-framework/blob/master/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java#L306-L308
This leads to two problems:
- Excessive heap garbage due to throw-away string creation
- Excessive CPU due to computing hash code for the newly created strings.
In our spring context present 1200+ beans and ~20 beanPostProcessors as result E2E spenario for 30 minute generate ~300GB char[]
!spring_get_cachekey.png|thumbnail!
It our problem that legacy part of system use BeanFactory.getBean instead of inject dependency correctly. But problem described above also affect application start time because spring for inject dependency also do getBean by Class and as result spring for each class iterate by all beans in context and generate cache key like:
protected Object getCacheKey(Class<?> beanClass, String beanName) {
return beanClass.getName() + "_" + beanName;
}
!spring_allocation_string_by_start.png|thumbnail!
!spring_hot_methods_by_start.png|thumbnail!
Affects: 4.2.2
Attachments:
- spring_allocation_string_by_start.png (85.23 kB)
- spring_get_cachekey.png (127.79 kB)
- spring_hot_methods_by_start.png (46.60 kB)
Issue Links:
- @EventListener does not work if put it at method in class that implements interface [SPR-13650] #18226
@EventListener
does not work if put it at method in class that implements interface
Referenced from: commits 7b711c4