-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[EventDispatcher] Performance of TraceableEventDispatcher::getNotCalledListeners() #43658
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
Could you create a small application that allows to actually work with something and trying different approaches to improve performance? |
@umulmrum Do you have any news for us? |
@xabbuh Unfortunately I haven't found the time yet - I hope to get started this week (but am also happy if someone else jumps in). |
We could find a way to access I'm putting a Help Wanted label on this issue in case someone would like to give it a try. I'd be happy to review/help. |
…ng not called listeners when tracing (Jean-Beru) This PR was squashed before being merged into the 6.1 branch. Discussion ---------- [DependencyInjection][EventDispatcher] Avoid instantiating not called listeners when tracing | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #43658 | License | MIT | Doc PR | This PR removes useless listeners instantiation when `TraceableEventDispatcher::getNotCalledListeners()` is called. Even if this PR is in WIP, I created it to allow comments from `@nicolas`-grekas (and anyone interested in of course). Commits ------- d4e60e9 [DependencyInjection][EventDispatcher] Avoid instantiating not called listeners when tracing
Description
I analyzed performance issues in my project in the dev environment when I saw that
TraceableEventDispatcher::getNotCalledListeners()
is using up quite a bit of CPU. This is because all event listeners are instantiated which means that their dependencies are also loaded which in my case ultimately leads to the instantiation of multiple Doctrine repositories and therefore lots of annotation loading (which will also be tracked by the profiler, leading to even worse performance). When removing the call togetNotCalledListeners()
, cache usage drops by 75% and wall time by 0.4s/30% which is significant even if it is "only" the dev environment. There were ~100 uncalled listeners.So my question is if others experience the same problem in a real-world project. If yes, I suggest to improve this, e.g. by doing one of the following:
debug:event-dispatcher
can tell if it is registered correctly. So I suppose it might be expendable, but could of course err.Some time ago @javiereguiluz also asked to improve performance here, see #31970, but it wasn't pursued any further.
Thanks for considering (I'm glad to help on the easier solutions if requested)!
The text was updated successfully, but these errors were encountered: