-
Notifications
You must be signed in to change notification settings - Fork 18k
x/net/http2: reduce allocations of (*clientConnReadLoop).handleReponse by 10% #37853
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
Comments
Hello @rs, great catching you here! Thank you and Sounds good to me, please send a CL. Perhaps let’s rename strs to valuesSlab, because that’s the parent slice that we’ll be using to create individual value slices each of capacity 1. |
Thanks. For the strs naming, I used the same as in |
Change https://golang.org/cl/223783 mentions this issue: |
Change https://golang.org/cl/224217 mentions this issue: |
Updates bundled http2 to x/net git rev 63522dbf7 http2: reduce allocations of (*clientConnReadLoop).handleReponse https://golang.org/cl/223783 (#37853) http2: remove unused errors https://golang.org/cl/220458 http2: remove unused stream struct fields https://golang.org/cl/219857 http2: fix typo in comment https://golang.org/cl/214602 http2: workaround TCPConn CloseWrite not being supported on Plan 9 https://golang.org/cl/209417 (#17906, #35904) Change-Id: I0e48f32247938c3858170bf419624367d4faef4b Reviewed-on: https://go-review.googlesource.com/c/go/+/224217 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reduce allocation by using 1 capacity slices out of a single pre-allocated slice for header values, similarly to how it is done in textproto.(*Reader).ReadMIMEHeader. name old time/op new time/op delta ClientResponseHeaders/___0_Headers-16 82.3µs ± 7% 76.4µs ± 4% -7.18% (p=0.000 n=10+10) ClientResponseHeaders/__10_Headers-16 101µs ± 2% 99µs ± 3% -2.00% (p=0.016 n=8+10) ClientResponseHeaders/_100_Headers-16 213µs ± 2% 202µs ± 4% -4.96% (p=0.000 n=9+9) ClientResponseHeaders/1000_Headers-16 2.28ms ± 1% 2.15ms ± 2% -5.58% (p=0.000 n=8+10) name old alloc/op new alloc/op delta ClientResponseHeaders/___0_Headers-16 4.60kB ± 0% 4.60kB ± 0% ~ (p=0.201 n=10+10) ClientResponseHeaders/__10_Headers-16 9.01kB ± 0% 8.66kB ± 0% -3.96% (p=0.000 n=10+10) ClientResponseHeaders/_100_Headers-16 54.4kB ± 0% 48.4kB ± 0% -11.01% (p=0.000 n=10+10) ClientResponseHeaders/1000_Headers-16 702kB ± 0% 595kB ± 0% -15.28% (p=0.000 n=10+9) name old allocs/op new allocs/op delta ClientResponseHeaders/___0_Headers-16 57.0 ± 0% 56.0 ± 0% -1.75% (p=0.000 n=10+10) ClientResponseHeaders/__10_Headers-16 135 ± 0% 123 ± 0% -8.89% (p=0.000 n=10+10) ClientResponseHeaders/_100_Headers-16 786 ± 0% 679 ± 0% -13.61% (p=0.000 n=10+10) ClientResponseHeaders/1000_Headers-16 8.14k ± 0% 7.11k ± 0% -12.65% (p=0.000 n=10+10) Fixes golang/go#37853 Change-Id: I0bc6d879293a202a2742a06aca0b6dacfae7fc5f Reviewed-on: https://go-review.googlesource.com/c/net/+/223783 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
What version of Go are you using (
go version
)?What did you do?
In our deployment,
(*clientConnReadLoop).handleReponse
is the 4th method creating the most allocations.By applying the same slice trick as in textproto.(*Reader).ReadMIMEHeader, we can save about 10% of the allocations:
Here is the patch:
Please tell me if it's worth a CL.
The text was updated successfully, but these errors were encountered: