-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Request controller argument is first resolved as Doctrine entity, causing 40-50ms performance loss #54337
Comments
You can use the |
@MatTheCat That is true, but that is not my point. The documentation (https://symfony.com/doc/current/controller.html, as well as the page you link) teaches us that we can obtain the Request object (through the request value resolver) by specifying just a Request argument in the controller function. In my opinion, the fact that resolution is attempted by the Doctrine entity resolver before the Request is unexpected behavior. One should not be required to specify what is assumed to be the default. The current configuration is therefore not sensible and should be changed. Or the documentation should explicity state that you should never rely on the type annotation alone and always specify which resolver should be used. |
I was not making a point, just giving you a short-term solution.
I cannot think of use-cases where it would be problematic to increase the |
There was one, not sure if that is still the case: doctrine/DoctrineBundle#1554 (comment) |
@smnandre the comment you linked mentions the It actually explains why “ |
#SimonPleaseTalkLessAndSleepMoreS07E07 .... 😶🌫️ |
That's a lot and that's surprising. Normally this should be fast because this should all be just about loading pregenerated code. |
Symfony version(s) affected
7.0.5
Description
For the tag
controller.argument_value_resolver
, theargument_resolver.request
service has a priority of 50, whiledoctrine.orm.entity_value_resolver
has a priority of 110. As a result, EntityValueResolver from DoctrineBundle first tries to resolve theSymfony\Component\HttpFoundation\Request
controller argument as an entity. This is nonsensical and will cause Doctrine to try to find an entity manager and repository for it. In my case this leads to an extra 40-50ms of Total execution time on average.By changing the priority of
argument_resolver.request
to 150, the Request argument is resolved immediately without this detour.How to reproduce
Create a clean installation of
symfony/skeleton
and requiresymfony/webapp-pack
. Create a controller with aRequest $request
function argument and visit it. Inspect the Performance profiler page for the request.Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: