Use HPACK spelling for HTTP/2 compression#2271
Open
pavel-ptashyts wants to merge 3 commits into
Open
Conversation
When compression is enforced, the request factory creates the default Accept-Encoding value as "gzip,deflate" for HTTP/1 compatibility. HTTP/2's HPACK static table contains "gzip, deflate", so the H2 frame writer missed the compact static entry for the generated default. Rewrite only the generated default while copying headers into HTTP/2 frames. User-supplied Accept-Encoding values keep their original spelling, and HTTP/1 output remains unchanged. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
Add a deterministic encoder test proving that the HPACK static-table spelling uses a one-byte indexed representation while the old spelling requires a literal value. Clarify that the JMH benchmark reports execution time and allocation; its return value prevents dead-code elimination but is not a separate JMH metric. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
pavel-ptashyts
force-pushed
the
perf/http2-accept-encoding-hpack
branch
from
July 20, 2026 15:08
7cb1653 to
44208e5
Compare
Replace the remaining non-ASCII punctuation in the touched HPACK benchmark so the source follows the repository guidelines in AGENTS.md. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
pavel-ptashyts
force-pushed
the
perf/http2-accept-encoding-hpack
branch
from
July 20, 2026 15:45
44208e5 to
527368f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Accept-Encodingvalue fromgzip,deflatetogzip, deflatewhile copying headers into HTTP/2 framesAccept-Encodingspelling and leave HTTP/1 output unchangedPerformance evidence
With Netty 4.2.15.Final and a fresh HPACK encoder:
gzip,deflate: 14 encoded bytesgzip, deflate: 1 encoded byte through the indexed static-table representationA short JMH validation on JDK 21 with
-prof gcmeasured 1032 B/op for the literal spelling and 680 B/op for the static-table spelling. Timing was noisy, so this PR relies on the deterministic wire-size test rather than claiming a stable CPU improvement.Validation
./mvnw -pl client -Dtest='org.asynchttpclient.netty.request.AcceptEncodingHpackTest,org.asynchttpclient.BasicHttp2Test#generatedAcceptEncodingUsesHpackStaticValueOverHttp2+userAcceptEncodingSpellingIsPreservedOverHttp2' test(3 tests)AcceptEncodingHpackBenchmark -f 1 -wi 3 -i 5 -w 500ms -r 500ms -prof gcBasicHttp2Testvalidation from the initial changeAttribution
Codex on behalf of Pavel Ptashyts