-
Couldn't load subscription status.
- Fork 38.8k
Description
Andy Wilkinson opened SPR-16918 and commented
In a typical Spring Boot app, a significant amount of the startup cost is due to org.springframework.beans.CachedIntrospectionResults.forClass(Class<?>). There's a direct cost in terms of the CPU time taken for introspection and a secondary cost due to increased memory usage and GC pressure.
In the vast majority of cases, the introspection results are retrieved beneath AbstractAutowireCapableBeanFactory.populateBean(String, RootBeanDefinition, BeanWrapper) so that it can retrieve the property descriptors and then filter them. If I short-circuit populateBean so that it returns early if the bean definition's property values are empty, an app that took 2.7 seconds to start then starts in as little as 2.3 seconds.
The short circuiting loses two pieces of functionality:
- The opportunity for
InstantationAwareBeanPostProcessorsto add property values @Requiredsupport
Boot itself doesn't make use of either of these so the current ~400ms cost is a high price to pay. I'd like to explore the possibility of lowering or removing this cost.
As far as I can tell only one of the built-in post-processors, RequiredAnnotationBeanPostProcessor, uses the property descriptors, and it only does so if the bean definition hasn't been marked to skip the required check. One possibility may be to retrieve the property descriptors lazily and for Boot to somehow mark its bean definitions with skipRequiredCheck.
Affects: 5.0.6
Issue Links:
- BeanDefinition-aware BeanPostProcessors should clear cache in case of bean definition reset [SPR-17126] #21663 BeanDefinition-aware BeanPostProcessors should clear cache in case of bean definition reset
Referenced from: commits 81cb740
0 votes, 6 watchers