-
Notifications
You must be signed in to change notification settings - Fork 38.4k
AopUtils#findAdvisorsThatCanApply can be slow with larger number of Aspects #32262
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
Comments
We intend to revisit core container performance concerns in 6.2 (see e.g. #28122), so let's see what we can do about AOP Advisor matching. In general, we are very controlled in terms of thread usage and rather concerned about locking effects (see e.g. #23501), so it would be very unusual for us to use parallel collection streams there. That said, for applications with such large numbers of beans and aspects, we might be able to find a different arrangement with a similar performance effect. I've put this issue into 6.2.x for that reason. |
One further note on parallel processing there is the order of the outcome. In general, we treat advisors as per their registration order. With parallel streams, we cannot guarantee that the The key question is why Which aspects are involved in your scenario with >100 aspects? |
Assuming that your advisors are mostly of type |
For wildcard type matches, there is https://bugs.eclipse.org/bugs/show_bug.cgi?id=532033 from six years ago which unfortunately never got released, apparently due to breaking Spring Framework tests - which I cannot reproduce (anymore), our spring-aop test suite passes with the suggested patch applied to the AspectJ With the current AspectJ 1.9.21, the patch is simply to uncomment lines 178-181 in In my investigation, I have not found any other advisor matching scenario with the same magnitude of performance expense. With the above AspectJ patch applied, there should be no need for parallel advisor checking anymore, at least not with |
If you don't receive any feedback on that old issue, please note that the current AspectJ issue tracker is now on GitHub: https://github.com/eclipse-aspectj/aspectj/issues |
A quick follow-up: We actually do have test failures in the test suite when the AspectJ patch is applied but not in the core AOP tests, rather in |
@jhoeller Thank you so much for your analysis and suggestions above. We are currently using Spring Framework 5.8.5 and I upgraded our aspectj dependency to 1.9.21 and included a copy of |
@jhoeller My apologies but after further testing I realized today that just upgrading aspectj dependency to 1.9.21 for us was sufficient to improve the long startup time. I also tested with |
That @caitsithx any chance you could re-run your benchmark scenario against AspectJ 1.9.21.1? It'd be great to understand whether there is a significant enough performance problem remaining. If that is still the case, we need to follow up with the AspectJ team to see what it takes to uncomment that block in |
A quick update: AspectJ 1.9.22 is out in the meantime, so please rather re-run your benchmarks against that version. |
I assume there is nothing more we can do about this from the Spring Framework side. For any further benchmarks, please run them against the latest AspectJ version and let us know if there is still anything to advocate for there. |
Re the KindedType fix with WildTypePattern.match:
|
In the application I'm currently working with, there are 7534 beans and 115 AOP aspects. However, I've noticed that the startup time of the Spring context is quite slow. After conducting some testing and profiling, I have identified an area that can be optimized: the org.springframework.aop.support.AopUtils#findAdvisorsThatCanApply method. This method sequentially determines which AOP advisors from a list of candidates are applicable for a specific bean class. This process occurs within the Spring initialization thread.
To improve the performance, I made some modifications to parallelize the determination process at the granularity of one candidate advisor. I then measured the number of method calls, the average execution time, and the total execution time of this method during the Spring startup for both the original and improved code. here is the result:

The text was updated successfully, but these errors were encountered: