perf: avoid relocking response stream references - #934
Draft
brentechols wants to merge 1 commit into
Draft
Conversation
brentechols
force-pushed
the
agent/reduce-response-ref-locking
branch
from
August 15, 2026 21:38
97c9a08 to
03773e4
Compare
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.
Summary
RecvStreaminstead of cloning at response completionMotivation
A normal client request currently reacquires the connection-wide stream mutex to clone its response handle after insertion, then reacquires it at response completion to clone the body handle. This creates both handles during the existing locked stream insertion and moves the body handle on completion.
ResponseFutureretains its original handle, preserving post-completion informational-response and push-promise access. Reference drops keep their existing locking behavior.Scope
This is independent of the receive-side send-buffer lock patch and is based directly on
master. Existing fixtures now cover ordinary and pushed response IDs after manual completion, plus post-completionpush_promises()andpoll_informational()behavior.Performance
Seven rotated 100,000-request pairs produced these medians:
Each variant won four of seven paired runs, so the current-thread result is effectively neutral and the multi-thread result is a small, noisy improvement. The 1 GiB sustained-transfer case showed no reliable gain, which is expected for a change aimed at request/reference churn.
Validation
cargo fmt --all -- --checkcargo check --all-targets --offlinecargo test -p h2 --lib --no-default-features --offline(428 passed, 1 ignored)cargo test -p h2-tests --offline(complete integration suite, including the 5,000-connection hammer test)