-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Slow prototype bean creation when migrating spring-boot 2.3.5 -> 2.4.1 #26369
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
Could you debug into it and see what causes the cache misses specifically? What kind of cache key is being computed, and how does |
Yes, a demo project would be useful. We are very interested in seeing how your prototype-scoped |
Just noticed that your From that perspective, you might not actually see a 5.2->5.3 regression but rather the effect of a recent fix that got backported to 5.2.x as well: #26019 - but you might not have encountered it in the latest 5.2.x release yet. I'm afraid this fix restores correct behavior; I highly recommend reachitecting your lookup approach to let Spring's container do its per-bean type management. |
Could you please try Framework 5.2.12 / Boot 2.3.7 as well, confirming that you're seeing the same performance difference there? In any case, our previous behavior there was clearly broken for changing bean types with new metadata elements to discover, once the first bean type did not expose any metadata elements at all. We could cache metadata for all occurring bean types of the same bean definition but that'd really be against the grain of our bean definition model. I'd rather recommend a custom lookup method that delegates to |
very nice demo! |
I can link real project :) repo - https://github.com/1c-syntax/bsl-language-server, some docs in english - https://1c-syntax.github.io/bsl-language-server/en) It is a Language Server Protocol implementation for 1C:Enterprise Platform internal language. One of its components is a static alanysis tool, implemented via "diagnostics" ("inspections" in terms of IntelliJ IDEA) All diagnostics implements base interface DiagnosticConfiguration is located here https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/infrastructure/DiagnosticConfiguration.java It is called from DiagnosticsConfiguration (see Main goal of These conditions depend on data in sorry if my explanations seem confusing :( |
key is a bean string identifier (camel-cased class name) |
yes, I see the same regression on Boot 2.3.7. |
oh yes, it works! I've removed Thank you so much! problem is solved and issue can be closed. May be 10bff05 deserves some mention in changelog, migration guide or logs. |
Thanks for the quick turnaround, good to hear that it works for you now! I've added a corresponding note to https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-5.x |
I had a cyclic dependency error on some bean loading after To resolve it I had to add some I could then get up to date (spring boot Sample error was:
Cheers, |
Affects: Spring Framework 5.3.2
I have a project (console based, environment=NONE, only base spring boot starter) with a lot of prototype bean creations at application runtime (not startup), ~15k of beans. I have one interface and near 150 different implemantions of it marked with
@Configuration
has@Bean
-method, some kind of object provider, which get bean of concrete class (not interface):On spring boot 2.3.5 15000 of
diagnostic
calls take 12 seconds. On spring boot 2.4.1 - more than 75 seconds. no changes to application code or configs, just dependency bump.On flame graph I discovered problem (synchonized issue) at CommonAnnotationBeanPostprocessor.findResourceMetadata
https://postimg.cc/3ywf5B6Q
Comparison of:
2.3.5: https://postimg.cc/HVdnQYLn
2.4.1: https://postimg.cc/KKw4LtKh
Looks like all bean creations on 2.3.5 took metadata from cache, while all creations at 2.4.1 have "cache miss" and are forced to recreate metadata.
I've asked about this at spring-boot gitter and was redirected here by @wilkinsona.
P.S. I'll try to provide some demo-project, need some time to reproduce it.
The text was updated successfully, but these errors were encountered: