Performance(medium, 1.13%): Lazily instantiate Enlight_Event_Handler_Default (would involve SW-PR) #67
Labels
enhancement
Issues that describe new features or improvements to existing features.
Shopware instantiates an instance of
Enlight_Event_Handler_Default
for every subscriber – even if the corresponding events are never triggered.In our default demo shops with none of our plugins enabled,
Shopware\Components\ContainerAwareEventManager->addListener
is called 125 times (2.99% of request processing time), and with 25 of our plugins, 890 times (3.30% of request processing time). That makes for a lot of unnecessary instances. The event handler's constructor takes about 1 % and 1.13 % of total request processing time, respectively.Instead, the handler could be lazily instantiated when necessary, i.e., when the event is first triggered. Until then, the constructor arguments could be cached.
https://github.com/VIISON/shopware/blob/939ed8f18cef093c20a79e4b45ca825923a30ec0/engine/Library/Enlight/Event/EventManager.php#L78
The text was updated successfully, but these errors were encountered: