Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Efficient type matching support for large number of beans [SPR-17528] #22060
During profiling the application, it was found that around 19% of time was spent in the various BeanFactory methods.
Our application has over 10K beans and around 3K beans loaded at startup (~10% of them during and remaining immediately after ApplicationContext refresh).
The existing cache inside of DefaultListableBeanFactory does help for subsequent lookups though.
It gave 10 seconds improvements however the lookup in the cache started showing up as the new hotspot.
Since the iteration over all the 10K bean definitions for every type lookup seemed to be the root cause, after several attempts, this is what I came up with (See PR).
Here is the JFR Hot Methods after applying the change:
This has helped speed up our application by around 25 seconds with no other change.
Also it would be great if the core implementation itself can support more efficient lookups for types with sizeable beans in the registry.
Affects: 5.1 GA
Referenced from: pull request #2021