ScheduledBeanLazyInitializationExcludeFilter is auto-configured even when annotation-based scheduled has not been enabled#33276
Closed
hpoettker wants to merge 1 commit into
Closed
ScheduledBeanLazyInitializationExcludeFilter is auto-configured even when annotation-based scheduled has not been enabled#33276hpoettker wants to merge 1 commit into
ScheduledBeanLazyInitializationExcludeFilter is auto-configured even when annotation-based scheduled has not been enabled#33276hpoettker wants to merge 1 commit into
Conversation
…`@EnableScheduling`
ScheduledBeanLazyInitializationExcludeFilter be conditional on @EnableSchedulingScheduledBeanLazyInitializationExcludeFilter is auto-configured even when annotation-based scheduled has not been enabled
snicoll
pushed a commit
that referenced
this pull request
Nov 21, 2022
Member
|
Thanks again @hpoettker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes the exposure of
ScheduledBeanLazyInitializationExcludeFilterconditional on the annotation@EnableScheduling.When the property
spring.main.lazy-initializationis set totrue, theLazyInitializationBeanFactoryPostProcessorcurrently applies theScheduledBeanLazyInitializationExcludeFilterto each bean definition. This is independent of whether the user has opted in to scheduling with@EnableSchedulingor not.The goal of the PR is to improve the start-up performance of applications that use lazy initialization but not scheduling. An example could be a short-lived Spring Batch app that contains multiple job beans but executes only a single job when started and exits afterwards. Such an app would not use scheduling and profits from not initializing all beans on start up.
I've assembled a toy application with a flame graph here: https://github.com/hpoettker/lazy-scheduler-demo
About 3% of the whole application run-time is spent on the
ScheduledBeanLazyInitializationExcludeFilter.The start-up time (as logged by the application) varies between runs. But on my machine it's about 0.65 seconds and reduces to 0.60 seconds when the
TaskSchedulingAutoConfigurationis excluded.