-
Notifications
You must be signed in to change notification settings - Fork 18.4k
net/textproto: eliminate some bounds checks #75126
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 change lifts bounds checks out of loops in the trim function. Here are some benchmark results (no change to allocations): goos: darwin goarch: amd64 pkg: net/textproto cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ ReadMIMEHeader/client_headers-8 3.531µ ± 3% 3.506µ ± 1% ~ (p=0.068 n=20) ReadMIMEHeader/server_headers-8 2.409µ ± 0% 2.384µ ± 1% -1.02% (p=0.000 n=20) Uncommon-8 545.2n ± 1% 536.7n ± 0% -1.58% (p=0.000 n=20) geomean 1.667µ 1.649µ -1.10%
This PR (HEAD: 580f35a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/698715. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from jub0bs: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Sean Liao: Patch Set 1: Auto-Submit+1 Code-Review+2 Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Sean Liao: Patch Set 1: -Run-TryBot Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-08-25T19:47:33Z","revision":"4fa8e5fa904738de531538ecf36bf5afd3b55ea6"} Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Sean Liao: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Sean Liao: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/698715. |
This change lifts bounds checks out of loops in the trim function.
Here are some benchmark results (no change to allocations):
goos: darwin
goarch: amd64
pkg: net/textproto
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
│ old │ new │
│ sec/op │ sec/op vs base │
ReadMIMEHeader/client_headers-8 3.531µ ± 3% 3.506µ ± 1% ~ (p=0.068 n=20)
ReadMIMEHeader/server_headers-8 2.409µ ± 0% 2.384µ ± 1% -1.02% (p=0.000 n=20)
Uncommon-8 545.2n ± 1% 536.7n ± 0% -1.58% (p=0.000 n=20)
geomean 1.667µ 1.649µ -1.10%