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

Do not use context manager for connection pool borrowing #51

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

bisho
Copy link
Member

@bisho bisho commented Nov 6, 2023

Turns out at this micro-optimization level a context manager is quite expensive. It builds an object to encapsulate the context and that adds gc pressure on top of overall slowness. Removing this provides 0.6-0.8us ~10% improvement and softens gc latency spikes in production.

Before:
multithreaded: Overall: 135509.96 RPS / 7.38 us/req
singlethreaded: Overall: 137630.69 RPS / 7.27 us/req
After:
multithreaded: Overall: 151058.43 RPS / 6.62 us/req
singlethreaded: Overall: 151288.67 RPS / 6.61 us/req

Before:
Screenshot 2023-11-06 at 12 27 19
After:
Screenshot 2023-11-06 at 12 27 34

@bisho bisho requested a review from a team November 6, 2023 11:34
@bisho bisho marked this pull request as ready for review November 6, 2023 11:34
@bisho bisho force-pushed the simple_optimizations branch from e967449 to 0c4aa30 Compare November 6, 2023 13:30
@bisho bisho force-pushed the context_manager branch 2 times, most recently from ded6e9b to 01562f1 Compare November 6, 2023 17:36
@bisho bisho force-pushed the simple_optimizations branch from 0c4aa30 to 949da4b Compare March 5, 2024 13:31
@bisho bisho force-pushed the context_manager branch from 01562f1 to e6de124 Compare March 5, 2024 13:31
@bisho bisho force-pushed the simple_optimizations branch from 949da4b to b06fbac Compare March 5, 2024 14:09
@bisho bisho force-pushed the context_manager branch from e6de124 to e4129fe Compare March 5, 2024 14:09
@bisho bisho force-pushed the simple_optimizations branch from b06fbac to 2fcb57c Compare March 5, 2024 14:12
@bisho bisho force-pushed the context_manager branch from e4129fe to 96661df Compare March 5, 2024 14:12
@bisho bisho force-pushed the simple_optimizations branch from 2fcb57c to dc9536d Compare March 5, 2024 14:13
@bisho bisho force-pushed the context_manager branch from 96661df to 69e9c39 Compare March 5, 2024 14:13
@bisho bisho force-pushed the context_manager branch from 69e9c39 to b56f41e Compare March 5, 2024 14:15
@bisho bisho changed the base branch from simple_optimizations to main March 5, 2024 14:15
@bisho bisho merged commit c82632e into main Mar 5, 2024
4 checks passed
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