-
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
baggage: more efficient member validation #5214
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5214 +/- ##
=======================================
- Coverage 84.5% 84.5% -0.1%
=======================================
Files 258 258
Lines 17110 17096 -14
=======================================
- Hits 14468 14452 -16
- Misses 2343 2345 +2
Partials 299 299
|
I don't think this PR needs a changelog entry. |
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.
I am ok with this
We tend to add changelog entries when we improve performance. |
Can you please provide a reference? I cannot find anything here: https://github.com/golang/go/pulls/kevinburkesegment |
Ah, this is my work account - all of my Go contributions are on the email under my other Github username, kevinburke, but also Google does not use Github for pull requests. That commit is here: golang/go@ed8f207 |
Instead of performing many, many comparisons for each character in a key and value, create an array of 128 bits and test for membership in that array, which is quicker. Benchmarks on a Mac M1, ran 20 times. ``` name old time/op new time/op delta New-8 747ns ± 4% 741ns ± 3% ~ (p=0.089 n=17+19) NewMemberRaw-8 11.4ns ± 1% 10.9ns ± 1% -4.67% (p=0.000 n=17+19) Parse-8 619ns ± 2% 603ns ± 1% -2.54% (p=0.000 n=18+18) String-8 1.12µs ± 4% 1.09µs ± 2% -2.65% (p=0.000 n=19+18) ValueEscape/nothing_to_escape-8 6.93ns ± 1% 6.94ns ± 0% +0.18% (p=0.012 n=18+20) ValueEscape/requires_escaping-8 26.3ns ± 2% 26.1ns ± 1% -0.91% (p=0.000 n=19+19) ValueEscape/long_value-8 641ns ± 4% 595ns ± 1% -7.14% (p=0.000 n=18+17) ```
b0243b3
to
7c71c1d
Compare
@open-telemetry/go-approvers waiting 1 day before merging. |
Instead of performing many, many comparisons for each character in a key and value, create an array of 128 bits and test for membership in that array, which is quicker.
Benchmarks on a Mac M1, ran 20 times.
The approach is taken from the same approach in
encoding/json
in the standard library, which I also contributed.