-
Notifications
You must be signed in to change notification settings - Fork 48
Rework header name scan to use optimised ByteString.indexOf #826
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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))