-
Notifications
You must be signed in to change notification settings - Fork 1.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
Speed up NextLabel and PrevLabel #1039
Conversation
This reduces readability, but they are in the hot path of coredns.
Codecov Report
@@ Coverage Diff @@
## master #1039 +/- ##
=========================================
+ Coverage 54.92% 55% +0.07%
=========================================
Files 41 41
Lines 9869 9879 +10
=========================================
+ Hits 5421 5434 +13
+ Misses 3425 3423 -2
+ Partials 1023 1022 -1
Continue to review full report at Codecov.
|
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 modulo some minor changes. I wanted to do this a while back, but never got around to it.
thank you both |
* change NextLabel and PrevLabel to be faster This reduces readability, but they are in the hot path of coredns. * @redyeti pointed out, that my implementation disregarded triple backslashes * add synthetic benchmark-tests for PrevLabel and NextLabel * rename ii -> j * invert compare * PrevLabel: add empty string check + test case * NextLabel: fix and add testcase for NextLabel("", offset>0)
NextLabel and PrevLabel are heavily used in the "file" plugin in coredns. This change introduces benchmark tests and improves the performance (on my machine).
It eliminates all allocations and uses strings in a way that should make L1-Cache-Hits more likely.
The time for coredns "file"-plugin Requests is cut roughly in half.