-
Notifications
You must be signed in to change notification settings - Fork 18.4k
mime: reduce allocs incurred by ParseMediaType #75565
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
base: master
Are you sure you want to change the base?
Conversation
This PR (HEAD: 7859830) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705715. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from jub0bs: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Emmanuel Odeke: Patch Set 2: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Go LUCI: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-21T20:37:59Z","revision":"2cd818d02d61de5d5c3d235c3c00dc3f81a4992c"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Emmanuel Odeke: Patch Set 2: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Go LUCI: Patch Set 2: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Go LUCI: Patch Set 2: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
Message from Damien Neil: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
7859830
to
c44e2a2
Compare
This PR (HEAD: c44e2a2) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705715. Important tips:
|
Message from jub0bs: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705715. |
This change is mostly gardening. It simplifies ParseMediaType and its
helper functions and reduces the amount of allocations they incur.
Here are some benchmark results:
goos: darwin
goarch: amd64
pkg: mime
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
│ old │ new │
│ sec/op │ sec/op vs base │
ParseMediaType-8 55.26µ ± 1% 54.54µ ± 1% -1.30% (p=0.000 n=20)
ParseMediaTypeBogus-8 3.551µ ± 0% 3.427µ ± 0% -3.48% (p=0.000 n=20)
geomean 14.01µ 13.67µ -2.39%
ParseMediaType-8 38.48Ki ± 0% 37.38Ki ± 0% -2.85% (p=0.000 n=20)
ParseMediaTypeBogus-8 2.531Ki ± 0% 2.469Ki ± 0% -2.47% (p=0.000 n=20)
geomean 9.869Ki 9.606Ki -2.66%
ParseMediaType-8 457.0 ± 0% 425.0 ± 0% -7.00% (p=0.000 n=20)
ParseMediaTypeBogus-8 25.00 ± 0% 21.00 ± 0% -16.00% (p=0.000 n=20)
geomean 106.9 94.47 -11.62%