-
Notifications
You must be signed in to change notification settings - Fork 18k
mime: speed up ParseMediaType #73436
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: ed6e916) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/666655. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
ed6e916
to
bc58098
Compare
This PR (HEAD: bc58098) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/666655. Important tips:
|
Message from Damien Neil: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from jub0bs: Patch Set 2: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from jub0bs: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Eschew UTF-8 decoding and strings.IndexFunc where possible, and rely on 128-bit bitmaps instead. Eliminate some bounds checks. Some benchmark results (no changes to allocations): 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 71.75µ ± 0% 55.53µ ± 0% -22.60% (p=0.000 n=20) ParseMediaTypeBogus-8 5.330µ ± 0% 3.603µ ± 0% -32.41% (p=0.000 n=20) geomean 19.56µ 14.14µ -27.67%
bc58098
to
e2293d6
Compare
This PR (HEAD: e2293d6) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/666655. Important tips:
|
Message from jub0bs: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from jub0bs: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Mateusz Poliwczak: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Jorropo: Patch Set 4: Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Go LUCI: Patch Set 4: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-04-22T20:07:44Z","revision":"40be37f3722b987b2fd692929513e5846a0c11d2"} Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Jorropo: Patch Set 4: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Go LUCI: Patch Set 4: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Go LUCI: Patch Set 4: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from jub0bs: Patch Set 4: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Junyang Shao: Patch Set 4: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Message from Dmitri Shuralyov: Patch Set 4: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/666655. |
Add benchmarks for ParseMediaType.
Eschew UTF-8 decoding and strings.IndexFunc where possible, and rely
on 128-bit bitmaps instead. Eliminate some bounds checks.
Some benchmark results (no changes to allocations):
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 71.75µ ± 0% 55.53µ ± 0% -22.60% (p=0.000 n=20)
ParseMediaTypeBogus-8 5.330µ ± 0% 3.603µ ± 0% -32.41% (p=0.000 n=20)
geomean 19.56µ 14.14µ -27.67%