-
Notifications
You must be signed in to change notification settings - Fork 15
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
Optimise allocations in ParseAccept #6
Open
pracucci
wants to merge
6
commits into
munnerz:master
Choose a base branch
from
grafana:performance-improvements-without-breaking-changes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Optimise allocations in ParseAccept #6
pracucci
wants to merge
6
commits into
munnerz:master
from
grafana:performance-improvements-without-breaking-changes
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goos: darwin goarch: arm64 pkg: github.com/munnerz/goautoneg │ original.txt │ step-2-slices-sort.txt │ │ sec/op │ sec/op vs base │ ParseAccept/#00-10 24.445n ± 0% 6.524n ± 0% -73.31% (p=0.002 n=6) ParseAccept/application/json-10 90.67n ± 1% 65.66n ± 0% -27.58% (p=0.002 n=6) ParseAccept/application/json,text/plain-10 152.7n ± 1% 125.3n ± 0% -17.94% (p=0.002 n=6) ParseAccept/application/json;q=0.9,text/plain-10 214.5n ± 0% 188.1n ± 0% -12.28% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 636.6n ± 1% 615.6n ± 1% -3.30% (p=0.002 n=6) geomean 135.8n 90.93n -33.05% │ original.txt │ step-2-slices-sort.txt │ │ B/op │ B/op vs base │ ParseAccept/#00-10 24.00 ± 0% 0.00 ± 0% -100.00% (p=0.002 n=6) ParseAccept/application/json-10 72.00 ± 0% 48.00 ± 0% -33.33% (p=0.002 n=6) ParseAccept/application/json,text/plain-10 120.00 ± 0% 96.00 ± 0% -20.00% (p=0.002 n=6) ParseAccept/application/json;q=0.9,text/plain-10 168.0 ± 0% 144.0 ± 0% -14.29% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 456.0 ± 0% 432.0 ± 0% -5.26% (p=0.002 n=6) geomean 109.7 ? ¹ ² ¹ summaries must be >0 to compute geomean ² ratios must be >0 to compute geomean │ original.txt │ step-2-slices-sort.txt │ │ allocs/op │ allocs/op vs base │ ParseAccept/#00-10 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.002 n=6) ParseAccept/application/json-10 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6) ParseAccept/application/json,text/plain-10 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6) ParseAccept/application/json;q=0.9,text/plain-10 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 5.000 ± 0% 4.000 ± 0% -20.00% (p=0.002 n=6) geomean 2.268 ? ¹ ² ¹ summaries must be >0 to compute geomean ² ratios must be >0 to compute geomean
According to https://httpwg.org/specs/rfc9110.html#field.accept, parsing parameters has been removed from the spec as it's no longer widely used. Removing parameter parsing means that Accept will only ever allocate once. Compared to the previous commit: goos: darwin goarch: arm64 pkg: github.com/munnerz/goautoneg │ step-2-slices-sort.txt │ step-4-without-params.txt │ │ sec/op │ sec/op vs base │ ParseAccept/#00-10 6.524n ± 0% 6.540n ± 1% ~ (p=0.056 n=6) ParseAccept/application/json-10 65.66n ± 0% 66.41n ± 1% +1.15% (p=0.009 n=6) ParseAccept/application/json,text/plain-10 125.3n ± 0% 123.7n ± 1% -1.28% (p=0.026 n=6) ParseAccept/application/json;q=0.9,text/plain-10 188.1n ± 0% 164.5n ± 1% -12.54% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 615.6n ± 1% 528.9n ± 0% -14.08% (p=0.002 n=6) geomean 90.93n 85.90n -5.54% │ step-2-slices-sort.txt │ step-4-without-params.txt │ │ B/op │ B/op vs base │ ParseAccept/#00-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹ ParseAccept/application/json-10 48.00 ± 0% 48.00 ± 0% ~ (p=1.000 n=6) ¹ ParseAccept/application/json,text/plain-10 96.00 ± 0% 80.00 ± 0% -16.67% (p=0.002 n=6) ParseAccept/application/json;q=0.9,text/plain-10 144.00 ± 0% 80.00 ± 0% -44.44% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 432.0 ± 0% 240.0 ± 0% -44.44% (p=0.002 n=6) geomean ² -23.78% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ step-2-slices-sort.txt │ step-4-without-params.txt │ │ allocs/op │ allocs/op vs base │ ParseAccept/#00-10 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=6) ¹ ParseAccept/application/json-10 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹ ParseAccept/application/json,text/plain-10 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹ ParseAccept/application/json;q=0.9,text/plain-10 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.002 n=6) ParseAccept/application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5-10 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.002 n=6) geomean ² -34.02% ² ¹ all samples are equal ² summaries must be >0 to compute geomean
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@munnerz Any chance of getting this merged? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is like #5 but reverting back the change that removed
Params
, given it currently breaks https://github.com/prometheus/common.In this PR we propose to use
golang.org/x/exp/slices.SortFunc
instead ofsort.Sort
. This requires Go 1.18+ as it uses generics.