Skip to content

Create async loop outside of benchmark #145

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

Merged
merged 3 commits into from
Nov 28, 2021

Conversation

jkimbo
Copy link
Member

@jkimbo jkimbo commented Oct 18, 2021

I realised that the async benchmark in #141 wasn't a fair comparison to the sync one because it was also including the async loop setup. This PR creates the async loop outside of the benchmark code to more accurately benchmark the actual query execution.

There is still some overhead with the async execution but it's no longer as bad as the first benchmark (more like ~20% slower rather than ~70%)
CleanShot 2021-10-18 at 11 57 22@2x

@jkimbo jkimbo requested a review from Cito as a code owner October 18, 2021 10:58
@jkimbo jkimbo requested review from Cito and removed request for Cito October 18, 2021 10:58
Copy link
Member

@Cito Cito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really useful observation and fix.

Can you add a small comment here in the code as well, explaining why it is important that you create the loop outside?

@Cito
Copy link
Member

Cito commented Oct 18, 2021

@jkimbo Does this also apply to the SQLAlchemy benchmark?

@jkimbo
Copy link
Member Author

jkimbo commented Oct 19, 2021

@jkimbo Does this also apply to the SQLAlchemy benchmark?

@Cito I don't think so because an async server would have created the event loop on start up so you wouldn't be creating a new one per request.

@Cito Cito force-pushed the main branch 3 times, most recently from 0ac79de to 3f40fc2 Compare November 7, 2021 20:26
@jkimbo jkimbo requested a review from Cito November 28, 2021 17:29
@Cito Cito merged commit b8dc402 into main Nov 28, 2021
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