avoid ByteString when parsing HTTP/2 headers#800
avoid ByteString when parsing HTTP/2 headers#800pjfanning wants to merge 4 commits intoapache:mainfrom
Conversation
pjfanning
commented
Sep 26, 2025
- experiment for Http2 header parser can be made more performant #798
- WIP
|
Breaks 1 Http2ClientSpec test |
5e2fe91 to
a1ac952
Compare
| httpHeaderParser.parseHeaderLine(pekko.util.ByteString(concHeaderLine))() | ||
| httpHeaderParser.resultHeader | ||
| } else { | ||
| HttpHeader.parse(name, value, httpHeaderParser.settings) match { |
There was a problem hiding this comment.
In general that's really cleaner. I don't expect a performance hit, there's a bit of a difference of how the parsers are looked up between HttpHeader.parse and httpHeaderParser.parseHeaderLine. HttpHeader.parse uses binary search to find the right parser and httpHeaderParser.parseHeaderLine uses kind of a lut / radix lookup once the parser is primed.
There was a problem hiding this comment.
Thanks @jrudolph.
I had to use the startsWith(":") check because HttpHeader.parse doesn't support pseudo headers and 1 test includes a :grpc-status pseudo header.
There was a problem hiding this comment.
But wait, does it even parse it into anything useful?
There was a problem hiding this comment.
I'll debug it later. There is an existing test that relies on the header parser not failing. Whether it needs the parser to actually process the pseudo header at all is something that I haven't yet tested.
There was a problem hiding this comment.
Maybe it's a typo in the test? Is :grpc-status a thing, i.e. is it allowed for gRPC (outside the HTTP/2 spec) to extend the set of : pseudo headers?
There was a problem hiding this comment.
pekko-grpc also doesn't use the colon form so maybe it's just a typo and we could just fix the test.
Added comments to clarify handling of pseudo-headers in the parseHeaderPair method.
| httpHeaderParser.parseHeaderLine(ByteString(concHeaderLine))() | ||
| httpHeaderParser.resultHeader | ||
| import HttpHeader.ParsingResult | ||
| if (name.startsWith(":")) { |
There was a problem hiding this comment.
Maybe just a look ahead char is better