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
OnClassCondition tries to determine the outcome for single auto-configuration classes in parallel #22294
OnClassCondition tries to determine the outcome for single auto-configuration classes in parallel #22294
Conversation
Prior to this commit, OnClassCondition started a thread even if the number of passed autoconfiguration class candidates never exceeded 1. This commit only starts a thread if there is actually work to split in half.
Nice find, @dreis2211! Thank you. The behaviour you've observed is a regression in Spring Boot 2.3. In 2.2 the filtering is only performed once for all of the auto-configuration classes. In 2.3, it's performed for all of the auto-configuration classes but then, as you have observed, it's performed many more times a single auto-configuration class at a time. I haven't yet had a chance to figure out why that is, but there may be an even bigger improvement to be found that restores 2.2's behaviour. |
6921fda introduced the change in behaviour. That was a good change to make. What you have proposed will just make it better. Thanks again. |
I found this commit as well and didn't consider it a regression. Thanks for keeping me in the loop. |
@dreis2211 While you were working on this, I'm curious if you tried avoiding the creation of the |
@wilkinsona I haven't because that seemed like it wouldn't be worth the effort. But feel free to give it a try. |
Prior to this commit, OnClassCondition started a thread even if the number of passed autoconfiguration class candidates never exceeded 1. This commit only starts a thread if there is actually work to split in half. See gh-22294
Thanks again, @dreis2211. I've yet to try avoiding creating the |
Thanks @wilkinsona . Let me know if I can help with the performance work in any way. |
Hi,
I just noticed that a vanilla Spring-Boot app (with
web
,security
andactuator
starters) creates 200+ threads on startup. After a small investigation those threads turned out to be created byOnClassCondition
. I noticed that threads are created even though the passedautoConfigurationClasses
array has a length of 1. (Only one invocation in the lifetime of the app has multiple classes passed). In those cases it seems to be wasteful to create threads because the work cannot be split in half, really.A small benchmark shows the following results:
Let me know what you think.
Cheers,
Christoph