Improve Performance of HTTPField.value - #146
Merged
Merged
Conversation
nerdsupremacist
force-pushed
the
mq-field-value-perf
branch
from
August 28, 2026 11:17
2043f6a to
a286394
Compare
fabianfett
self-requested a review
August 28, 2026 11:42
nerdsupremacist
force-pushed
the
mq-field-value-perf
branch
2 times, most recently
from
August 28, 2026 12:22
b93e474 to
f752f2f
Compare
fabianfett
pushed a commit
that referenced
this pull request
Aug 28, 2026
### Motivation In #146 we're going to be revamping the internal structure and implementation of how we store values for http fields. To do it safely, I want to add a few tests to make sure we do not regress it ### Modifications Added tests for all the edge cases I could come up with for HTTP Field Values ### Result Tests Pass
nerdsupremacist
force-pushed
the
mq-field-value-perf
branch
from
August 28, 2026 13:11
f752f2f to
158619b
Compare
guoye-zhang
reviewed
Aug 28, 2026
I made a mistake in the previous commit updating the thresholds
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.
Motivation
When instantiating new HTTPFields, the values need to be validated, legalized and turned into the internal representation.
We use this representation to expose a string in
HTTPField.valueas well as to iterate over raw bytes usingHTTPField.withUnsafeBytesOfValue.Currently the internal representation is to use a ISO Latin 1 String to store the bytes only once. This however means that we need to transcode back and forth for non ascii values, which causes a lot of extra computations and allocations.
Modifications
HTTPField.Valuerather thanISOLatin1StringwithUnsafeBytesOfValuemassively andHTTPField.valuea little bitResult
These are the changes on the benchmarks added in this PR