-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
mysql/conn: do not allocate during writes #14482
Conversation
Signed-off-by: Vicent Marti <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Hello! 👋 This Pull Request is now handled by arewefastyet. The current HEAD and future commits will be benchmarked. You can find the performance comparison on the arewefastyet website. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice little improvement
❤️ This is a really nice improvement. |
Description
This is an outlier in the profiles for OLTP benchmarks. There's a lot of wasteful allocations and CPU usage in the write path for the MySQL connection for two reasons:
Timer
s for flushing every write call. To fix this, keep a singleTimer
and callReset
.getConn
for every write call. The closure contains the cleanup required after the write (unlocking the buffer and triggering the flush), but it captures the connection pointer itself, so it keeps allocating. Fix this by inlininggetConn
and deferring the cleanup only when required.Flame graph comparison (the size relative size difference is accurate):
Before (CPU)
After (CPU)
Before (Allocs)
After (Allocs)
cc @harshit-gangal @systay
Related Issue(s)
Checklist
Deployment Notes