perf(h1): pass ParserConfig by reference instead of cloning per parse call#4029
Open
DioCrafts wants to merge 1 commit intohyperium:masterfrom
Open
perf(h1): pass ParserConfig by reference instead of cloning per parse call#4029DioCrafts wants to merge 1 commit intohyperium:masterfrom
DioCrafts wants to merge 1 commit intohyperium:masterfrom
Conversation
Change ParseContext.h1_parser_config from owned ParserConfig to &ParserConfig. This avoids cloning the parser config on every HTTP/1 parse iteration, reducing allocations in the hot path. - mod.rs: Change field type from ParserConfig to &'a ParserConfig - conn.rs: Pass reference instead of clone - io.rs: Remove .clone() call when building ParseContext - role.rs: Update 20 test sites to pass references
Member
|
From the previous PR:
|
Author
Hi @seanmonstar, |
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.
Description:
ParseContextowned a fullParserConfigvalue. Every HTTP/1 parse iteration cloned it from the connection state, even though the config never changes mid-connection.This PR changes
h1_parser_configfromParserConfigto&'a ParserConfig. The clone disappears and the borrow checker guarantees the reference stays valid for the parse call.What changed
ParseContext.h1_parser_config: ownedParserConfig→&'a ParserConfigconn.rs: removed.clone()when buildingParseContextio.rs: same removal in the buffered I/O parse pathrole.rs: updated 20 test call sites to pass referencesNo public API changes, no behavioral changes. All existing tests pass.