{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/26993","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/26993/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/26993/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/26993/events","html_url":"https://github.com/symfony/symfony/issues/26993","id":316424272,"number":26993,"title":"Compiled EventSubscriber for possible performance optimization","user":{"login":"grisendo","id":1665659,"avatar_url":"https://avatars2.githubusercontent.com/u/1665659?v=4","gravatar_id":"","url":"https://api.github.com/users/grisendo","html_url":"https://github.com/grisendo","followers_url":"https://api.github.com/users/grisendo/followers","following_url":"https://api.github.com/users/grisendo/following{/other_user}","gists_url":"https://api.github.com/users/grisendo/gists{/gist_id}","starred_url":"https://api.github.com/users/grisendo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grisendo/subscriptions","organizations_url":"https://api.github.com/users/grisendo/orgs","repos_url":"https://api.github.com/users/grisendo/repos","events_url":"https://api.github.com/users/grisendo/events{/privacy}","received_events_url":"https://api.github.com/users/grisendo/received_events","type":"User","site_admin":false},"labels":[{"id":151519,"url":"https://api.github.com/repos/symfony/symfony/labels/EventDispatcher","name":"EventDispatcher","color":"DDDDDD","default":false},{"id":100378,"url":"https://api.github.com/repos/symfony/symfony/labels/Feature","name":"Feature","color":"02e10c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-20T22:01:53Z","updated_at":"2018-04-22T10:00:04Z","closed_at":null,"author_association":"NONE","body":"| Q                | A\r\n| ---------------- | -----\r\n| Bug report?      | no\r\n| Feature request? | yes\r\n| BC Break report? | no\r\n| RFC?             | yes\r\n| Symfony version  | x\r\n\r\nI was doing some debugging with a custom CMS made with Symfony (3.x) using Blackfire, in order to improve the performance as much as possible. I am not a profiler expert, but I saw that a huge amount of time was spent with \"EventDispatcher\" class, at \"sortListeners\" method. So, I was thinking: I always add events listeners/subscribers using tags in service container, so why subscribed classes are not already added and sorted in the container when compiling? Why not to create a CompiledEventSubscriber that you can optionally use instead of normal one, if you are pretty sure you only work with container-tag defined event subscriptions?\r\n\r\nI don't know if there is already something about this topic, I was discussing it today at Slack, and @ostrolucky show me his own solution: https://github.com/ostrolucky/app-event-dispatcher/blob/master/src/Symfony/DependencyInjection/RegisterListenersPass.php\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/383369315","html_url":"https://github.com/symfony/symfony/issues/26993#issuecomment-383369315","issue_url":"https://api.github.com/repos/symfony/symfony/issues/26993","id":383369315,"user":{"login":"ostrolucky","id":496233,"avatar_url":"https://avatars2.githubusercontent.com/u/496233?v=4","gravatar_id":"","url":"https://api.github.com/users/ostrolucky","html_url":"https://github.com/ostrolucky","followers_url":"https://api.github.com/users/ostrolucky/followers","following_url":"https://api.github.com/users/ostrolucky/following{/other_user}","gists_url":"https://api.github.com/users/ostrolucky/gists{/gist_id}","starred_url":"https://api.github.com/users/ostrolucky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ostrolucky/subscriptions","organizations_url":"https://api.github.com/users/ostrolucky/orgs","repos_url":"https://api.github.com/users/ostrolucky/repos","events_url":"https://api.github.com/users/ostrolucky/events{/privacy}","received_events_url":"https://api.github.com/users/ostrolucky/received_events","type":"User","site_admin":false},"created_at":"2018-04-22T10:00:04Z","updated_at":"2018-04-22T10:00:04Z","author_association":"CONTRIBUTOR","body":"Yeah I guess bottleneck in your case is initializing of listeners, not sorting them. Moving sorting part to compiling would save just few krsort calls, rest of the code would still need to be executed at runtime."}}
{"actor":{"display_login":"ostrolucky"}}