Open LastDragon-ru opened 2 years ago
I've found that cache should be disabled while the AST Manipulation phase (because directives/args can change), so the first post updated.
I've also found that ValidatorDirective
doesn't not call Validator::setArgs()
after ValidatorDirective::setArgumentValue()
call that is critical when directives cached. The first post updated.
This change has the potential for a subtle breakage, exactly due to directives such as ValidatorDirective
that have lingering state. The same might be true for custom directives.
The PHP compatiblity can be resolved by using SplObjectStorage
. I would be happy about a pull request so I can benchmark this for our application.
This change has the potential for a subtle breakage, exactly due to directives such as ValidatorDirective
Yep. Also, a bit related issue: BaseDirective::hydrate()
doesn't reset cached args.
I would be happy about a pull request so I can benchmark this for our application.
In our real/live application, we have improvements of about ~6%. I will try to create PR next week, but no promises.
We intensively use directives and some of our queries return hundreds and thousands of objects. I've found that each call of
DirectiveLocator::associated($node)
create new instances of directives and this lead to (for 500 objects)In PHP 8.0 it is possible to use
WeakMap
to cache directive instances and we will get:Unfortunately, I have no idea (and time) how to fix it for PHP < 8.0