-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add simple execute benchmarks for both sync and async execution #141
Conversation
bb81c04
to
dcf2672
Compare
Hi @jkimbo, thanks for adding the benchmarks. The reason is that execution methods like |
I always wanted to check whether we can make it faster by statically defining the |
@Cito that makes sense however I created this benchmark because we are seeing significant performance issues when using async resolvers that are non trivial. For example @ThirVondukr created this benchmark that uses SQLAlchemy Async to fetch 250 records from the DB and it performs significantly worse than the equivalent sync versions: jkimbo/graphql-benchmarks#2 I'll experiment with improving the async performance and let you know how it goes in #142 |
After having work on improving async performance in Quiver, some of the findings are:
|
@syrusakbary Thanks for the feedback. Yes, the first issue you mention causes some overhead. I have also created issue #143 to discuss your second point. @jkimbo Always good to have real-world benchmarks. It may well be that, particularly for simple queries and a local database and with connection pooling, the database access can be so fast that the Python overhead in the ORM or GraphQL-core really matters. The other question here is whether SQLAlchemy also has some overhead when using it asynchronously, so it is unclear which part of the effect is due to GraphQL-core. We need some more experiments and profiling here. I found an interesting article by Mike Bayer that touches these questions. Let's continue the discussion in #142. |
@syrusakbary I don't understand what you mean here:
Could you elaborate? @Cito That is a fair point about there being overhead with async. I think it's fair to assume that there will always be some overhead with the async execution in sequential benchmarks, like we have here, since that's not really where async is beneficial. That is worth keeping in mind when we try and optimise the async call path. |
Both GraphQL and REST(labeled as SQLAlchemy + FastAPI Rest) servers use same function to query data, |
This PR adds 2 new benchmarks for to check execution both in a sync and async context.
Running these benchmarks has highlighted that the async execution in graphql-core is significantly slower than the sync execution (~70% slower). @Cito any idea why that might be? It's much higher than I would have expected.