-
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
go/stats: improve performance of safeJoinLabels #16953
Conversation
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
|
67b10c5
to
7ca2207
Compare
safeJoinLabels is in a pretty hot path for builtinbackupengine, every Read/Write file operation requires 2 calls to this function through (*scopedStats).TimedIncrementBytes. An optimization pass to this function was pretty low hanging fruit compared to trying to materialize/cache the label values correctly. ``` $ benchstat {before,after}.txt goos: darwin goarch: arm64 pkg: vitess.io/vitess/go/stats cpu: Apple M1 Max │ before.txt │ after.txt │ │ sec/op │ sec/op vs base │ SafeJoinLabels/no_combined-10 204.40n ± 1% 84.58n ± 0% -58.62% (p=0.000 n=10) SafeJoinLabels/combined-10 87.54n ± 9% 30.98n ± 1% -64.60% (p=0.000 n=10) geomean 133.8n 51.19n -61.73% │ before.txt │ after.txt │ │ B/op │ B/op vs base │ SafeJoinLabels/no_combined-10 152.00 ± 0% 48.00 ± 0% -68.42% (p=0.000 n=10) SafeJoinLabels/combined-10 104.00 ± 0% 24.00 ± 0% -76.92% (p=0.000 n=10) geomean 125.7 33.94 -73.00% │ before.txt │ after.txt │ │ allocs/op │ allocs/op vs base │ SafeJoinLabels/no_combined-10 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.000 n=10) SafeJoinLabels/combined-10 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10) geomean 2.828 1.000 -64.64% ``` Signed-off-by: Matt Robenolt <matt@ydekproductions.com>
7ca2207
to
623a744
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #16953 +/- ##
==========================================
+ Coverage 69.41% 69.42% +0.01%
==========================================
Files 1570 1570
Lines 203929 204000 +71
==========================================
+ Hits 141551 141622 +71
Misses 62378 62378 ☔ View full report in Codecov by Sentry. |
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.
LGTM
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!
I think it's ok to merge this without requiring an issue. |
safeJoinLabels is in a pretty hot path for builtinbackupengine, every Read/Write file operation requires 2 calls to this function through (*scopedStats).TimedIncrementBytes.
An optimization pass to this function was pretty low hanging fruit compared to trying to materialize/cache the label values correctly.
This showed up as the top offender of allocations in pprofs I was looking at:
Related Issue(s)
Checklist
Deployment Notes
None