Sylius: Please make Sylius more efficient!

Created on 24 Dec 2019  Â·  2Comments  Â·  Source: Sylius/Sylius

Describe the proposed solution
Kindly make Sylius faster by rewriting the event listeners. The kernel.request and kernel.response listeners should be fast, as they are invoked every time and waste lots of CPU cycles when there's no need to (eg. generating thumbs with liip).

I'm talking about ones that have large dependency trees, eg. the SessionCartSubscriber which pulls CartContextInterface and CartStorageInterface which in turn pulls again lots of other objects, including Doctrine related repositories.

Instead of:

    public function __construct(CartContextInterface $cartContext, CartStorageInterface $cartStorage)
    {
        $this->cartContext = $cartContext;
        $this->cartStorage = $cartStorage;
    }

Why not pull services via the container directly:

    private $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

I'm aware this is against SOLID, but this is not an ordinary domain object. This class should be fast to invoke.

Same goes to: NonChannelLocaleListener, RequestLocaleSetter and CheckoutResolver

Describe alternatives you've considered
I'm going to proxy those classes by myself. But the speed & performance should be out of the box.

Most helpful comment

It would be great to have some data before making such a decision. Could you maybe profile Sylius with a Blackfire or some similar tool before and after the change? Ideally, it would be both in prod and dev environments 😄

All 2 comments

Do you have a bench of the performance increase ?
Currently, there are many cache technologies that make the whole shop really fast.
But indeed, Sylius on small env (local for sure ) is a bit slow. But sacrificing perfs for a good developer experience is not that bad if the final rendering in production is fast imo.

It would be great to have some data before making such a decision. Could you maybe profile Sylius with a Blackfire or some similar tool before and after the change? Ideally, it would be both in prod and dev environments 😄

Was this page helpful?
0 / 5 - 0 ratings