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

Decode cache responses faster #1

Merged
merged 2 commits into from
Aug 12, 2022
Merged

Conversation

bboreham
Copy link
Collaborator

I coded scanGetResponseLine() using IndexByte() instead of SScanf().
Also added a benchmark.

name                   old time/op    new time/op    delta
ScanGetResponseLine-4    4.06µs ± 1%    0.13µs ± 4%  -96.89%  (p=0.008 n=5+5)

name                   old alloc/op   new alloc/op   delta
ScanGetResponseLine-4      128B ± 0%       24B ± 0%  -81.25%  (p=0.008 n=5+5)

name                   old allocs/op  new allocs/op  delta
ScanGetResponseLine-4      7.00 ± 0%      1.00 ± 0%  -85.71%  (p=0.008 n=5+5)

(Note I still copy the line to a string, because we need a string to put in Item.Key. I'm copying more than is strictly needed but it simplifies the code)

@bboreham bboreham merged commit 44b6cde into grafana:master Aug 12, 2022
bboreham added a commit to grafana/mimir that referenced this pull request Aug 15, 2022
Move to a Grafana fork of bradfitz/gomemcache, retaining the custom
dialer from the previous 3rd-party fork and adding optimized parsing
code from grafana/gomemcache#1.

Note this is based off a slightly newer base, which adds a `Ping`
method.
@bboreham
Copy link
Collaborator Author

Upstream PR at bradfitz#154

bboreham added a commit to grafana/mimir that referenced this pull request Aug 19, 2022
Move to a Grafana fork of bradfitz/gomemcache, retaining the custom
dialer from the previous 3rd-party fork and adding optimized parsing
code from grafana/gomemcache#1.

Note this is based off a slightly newer base, which adds a `Ping`
method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant