grails-core
grails-core copied to clipboard
Performance Improvement: Enable Lazy Initialization
Spring Boot 2.2 M1, Provide a configuration option to enable lazy initialisation, see https://spring.io/blog/2019/03/14/lazy-initialization-in-spring-boot-2-2
related issue: https://github.com/grails/grails-core/issues/12500
Is this ready for review?
@puneetbehl Need more unit tests, and running tests for real projects. In a simple demo project, it's OK now, but in my one complex project, there are strange behavior, some controllers in plugins are not loaded. I have to be sure that this feature doesn't have many side effects.
When enable lazy initialization in Grails 5.1.8-SNAPSHOT, in a newly created application, the amount of beans reduced from 353 to 124 during application startup, total 229 beans are not be created and its dependencies will not be injected.
In my real project, there are two beans should not be initialized lazily, gormDispatchEventRegistrar
and convertersConfigurationInitializer
. They could be excluded from lazy initialization by using LazyInitializationExcludeFilter
.
Also, there is a solution, which is to explicitly set bean.lazyInit=false
in the bean definition, which is more convenient for Grails users.
@puneetbehl Do you have time to look at this, and how did you think about it?