Rework header name scan to use optimised ByteString.indexOf#826
Rework header name scan to use optimised ByteString.indexOf#826pjfanning wants to merge 2 commits intoapache:mainfrom
Conversation
caf78cb to
89470c1
Compare
Update HttpHeaderParser.scala Update HttpHeaderParser.scala
89470c1 to
59b78eb
Compare
|
Are there benchmarks for this, if so can you post the difference otherwise would it be possible to create some benchmarks and post the results? |
There was a problem hiding this comment.
Pull request overview
This PR refactors the HTTP header name scanning logic to use an optimized ByteString.indexOf method instead of character-by-character scanning. The primary goal is to improve performance in the happy path by leveraging native indexOf implementation.
- Replaces
scanHeaderNameAndReturnIndexOfColonwith directindexOfcall and two new helper functions - Moves illegal character validation to occur during header name string construction rather than during colon search
- Validates the entire header name (from lineStart to colon) rather than only the portion after trie matching
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala
Outdated
Show resolved
Hide resolved
I'll come up with some benchmark numbers |
|
I ran the existing benchmark and the results are similar, with and without this change. HeaderParserBenchmark.bench_parse_headers I'll leave this for now but may come back to it to see if it is worth continuing. |
indexOf(char, start, end))