Skip to content
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

Fix: reduce async runtime blocking #1336

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Conversation

vlad-ivanov-name
Copy link
Collaborator

This PR aims to optimize request latency by reducing async runtime blocking

  • all functions of graphql objects are blocking, and many trigger file i/o. However, graphql requests were being executed via an async function. Use sync version of graphql execution and use tokio::spawn_blocking
  • use tokio::spawn_blocking for operations involving file i/o
  • reduce sync mutex lock regions where possible

Performance

  • std::sync::Mutex should be very efficient when there's no contention, and none is expected in graphql routines
  • I've benchmarked the overhead of tokio::spawn_blocking, since it's used more now: on my computer (core i5 macbook) I can spawn and .await around 90k tasks per second, which is at least two orders of magnitude away from the number of requests Josh can currently handle per second.

commit-id:bd8098e1

This PR aims to optimize request latency by reducing async runtime
blocking

* all functions of graphql objects are blocking, and many trigger file
i/o. However, graphql requests were being executed via an async
function. Use sync version of graphql execution and use
tokio::spawn_blocking
* use tokio::spawn_blocking for operations involving file i/o
* reduce sync mutex lock regions where possible

### Performance

* std::sync::Mutex should be very efficient when there's no contention,
and none is expected in graphql routines
* I've benchmarked the overhead of tokio::spawn_blocking, since it's
used more now: on my computer (core i5 macbook) I can spawn and .await
around 90k tasks per second, which is at least two orders of magnitude
away from the number of requests Josh can currently handle per second.

commit-id:bd8098e1
@vlad-ivanov-name vlad-ivanov-name merged commit 3768e10 into master Jun 13, 2024
1 check passed
@vlad-ivanov-name vlad-ivanov-name deleted the fix-graphql-blocking branch June 13, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants