Skip to content

Streamline HTTP/2 request header copy#2181

Open
hyperxpro wants to merge 1 commit into
mainfrom
perf/h2-header-copy
Open

Streamline HTTP/2 request header copy#2181
hyperxpro wants to merge 1 commit into
mainfrom
perf/h2-header-copy

Conversation

@hyperxpro
Copy link
Copy Markdown
Member

Motivation:

sendHttp2Frames copies HTTP/1.1 headers into Http2Headers on every HTTP/2 request (hot path):
String-materializes each name, toLowerCase() per name, HashSet probe — plus a
path + "?" + query concat for :path.

Modification:

:path from Uri.toRelativeUrl() (pooled, byte-identical); copy via iteratorCharSequence() +
AsciiString.contentEqualsIgnoreCase against HttpHeaderNames, dropping HTTP2_EXCLUDED_HEADERS.
Still lowercases (validating DefaultHttp2Headers throws on uppercase) but allocation-free when
already lowercase. Adds wire + :path-equivalence tests; updates the JMH benchmark.

Result:

Behavior-preserving; ~1.17x faster, -24 B/op (JMH, JDK 11). Full CI matrix green.

public void setup() {
// Representative request header set built the way NettyRequestFactory builds it:
// names are AsciiString constants from HttpHeaderNames.
headers = new DefaultHttpHeaders(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants