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
Improve performance by disabling return/resolved values validation #1493
Comments
My instinct says that the additional check for whichever setting controls this behaviour might eat up some of the benefits afforded by it. Making this as fast as possible would require having a code path that does no checks at all, but also does not checks if that behaviour is enabled. This would require duplicating/rewriting substantial parts of the executor, as well as possibly swapping the default field resolver and other parts that have sanity/safety checks. Feel free to explore this in a pull request, along with benchmarks to test the effectiveness. You can also use a custom executor in your own project, see graphql-php/src/Executor/Executor.php Line 78 in 3ae4185
|
FTR I would be interested in this. Once payloads returned exceed a significant size (in the multi-mega-byte range), I've seen that when profiling (used xdebug & PhpStorm xdebug snapshot analyzer) the micro-overhead for a single field becomes measurable in the big picture to the point it starts to rival the slowest part in those requests, usually the database. |
FTR? |
For The Record |
btw https://github.com/zalando-incubator/graphql-jit have thing called
I will try to make test in few days to see what's the gain. @mfn can you point me where most execution time comes from? |
@spawnia another thing that could improve performance is skipping
in case if document is cached. If document is cached - it was already validated somewhere in the past. |
basically 100-200ms improvement on one specific query on our side.
But i'm not sure how to incorporate this into here. I basically copied StandardServer, Helper and Grapql::promiseToExecute into my bundle in order to achieve that. https://github.com/Warxcell/graphql-bundle/blob/main/src/Controller/GraphQL.php#L231-L257 Any advice how to proceed with this one? |
I've tested with blackfire, and from 300ms total response time, we have 80ms lost in @spawnia what about using |
The performance of an API is a key point. Any small improvement in the response time would be very interesting! (and these benchmarks look promising) |
you can achieve same results by copy-paste-modify StandardServer.php You can see what I've done here: https://github.com/Warxcell/graphql-bundle/blob/main/src/Controller/GraphQL.php ( think https://github.com/Warxcell/graphql-bundle/blob/main/src/Controller/GraphQL.php#L254-L280 is the most important part - it skips parsing && validation of query if its cached) The question is - Can we incorporate that directly into this package? |
I don't want to change the default behaviour of this library in production settings. I very much appreciate how it prevents bad data from ever reaching clients, since we can be fearless and not use defensive programming there. |
What do you think about this one? The use-case is to gain a little bit of performance, by disabling resolver's returned value validation - and just trusting it.
No idea how much will gain - just throwing it in the wild and see what people think. :)
The text was updated successfully, but these errors were encountered: