Skip to content
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

x/net/http2: generate static table in hpack module before runtime #55881

Closed
Thorleon opened this issue Sep 26, 2022 · 2 comments
Closed

x/net/http2: generate static table in hpack module before runtime #55881

Thorleon opened this issue Sep 26, 2022 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Milestone

Comments

@Thorleon
Copy link
Contributor

Thorleon commented Sep 26, 2022

As the static version of headerFieldTable in hpack module is generated in runtime, we may use the go:generate to prepare the struct before the initialization phase.
This is supposed to save init time and allocations for many binaries, as net/http imports hpack.

Before:
init golang.org/x/net/http2/hpack @1.1 ms, 0.097 ms clock, 21240 bytes, 29 allocs
After:
init golang.org/x/net/http2/hpack @0.67 ms, 0.015 ms clock, 8120 bytes, 9 allocs

We also could add isStatic field, so we will be able to remove less readable pointer comparison in the idToIndex method and again reduce allocations. BenchmarkEncoderSearchTable is okay with this:

EncoderSearchTable-8 6.75µs ± 7% 6.57µs ± 6% ~ (p=0.099 n=10+10)

@gopherbot
Copy link

Change https://go.dev/cl/434875 mentions this issue: x/net/http2: generate static table in hpack module

@dmitshur
Copy link
Contributor

CC @neild, @tombergan.

@dmitshur dmitshur added Performance NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 26, 2022
@dmitshur dmitshur added this to the Unreleased milestone Sep 26, 2022
WeiminShang added a commit to WeiminShang/net that referenced this issue Nov 16, 2022
As the static version of headerFieldTable in hpack is generated in runtime,
we may use the go:generate to prepare the struct before the initialization phase.
This is supposed to save init time and allocations for many binaries,
as net/http imports hpack.

Before:
init golang.org/x/net/http2/hpack @1.1 ms, 0.097 ms clock, 21240 bytes, 29 allocs
After:
init golang.org/x/net/http2/hpack @0.67 ms, 0.015 ms clock, 8120 bytes, 9 allocs

Fixes golang/go#55881

Change-Id: Ia6575f67ffcba7cc4d75899b24a9c56deb58ccac
Reviewed-on: https://go-review.googlesource.com/c/net/+/434875
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 25, 2022
@golang golang locked and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Performance
Projects
None yet
Development

No branches or pull requests

3 participants