Batch bodyless HEADERS flushes in the H2 downstream write loop - #772
Merged
Merged
Conversation
d7840df flushed the ring buffer once per bodyless response so the stream could be completed after its bytes reached the wire. That broke HEADERS batching and cost one TLS record and syscall per response, dropping bodyless H2 proxy throughput by about 40%. Defer the completions into a list drained after the existing batched flush instead. Completion still happens only after the wire write.
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.
Fixes a bodyless H2 throughput regression introduced by d7840df (#764).
The write loop flushed the ring buffer once per bodyless response header so the stream could be completed after its bytes reached the wire. That broke HEADERS batching: every 0-byte response paid its own TLS record and syscall. With-body responses were unaffected.
This defers the CompleteResponse/checkout calls into a list drained at the end of the existing batched flush. Completion ordering is preserved: it still runs only after the wire write.
Measured with benchmark-throughput (ServeH2 True, body 0, proxy on): 82k ops/s before, 135k ops/s after, matching the pre-regression level. All 59 H2Serve tests pass.