Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Improvement: Enable Lazy Initialization #12501

Closed
wants to merge 4 commits into from

Conversation

rainboyan
Copy link
Contributor

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: #12500

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
@rainboyan rainboyan marked this pull request as draft May 5, 2022 11:05
@puneetbehl
Copy link
Contributor

Is this ready for review?

@rainboyan
Copy link
Contributor Author

@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.

@rainboyan rainboyan marked this pull request as ready for review May 13, 2022 10:58
@rainboyan
Copy link
Contributor Author

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.

@rainboyan
Copy link
Contributor Author

@puneetbehl Do you have time to look at this, and how did you think about it?

@rainboyan rainboyan closed this Sep 9, 2022
@rainboyan rainboyan deleted the enable_lazy_initialization branch September 9, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants