Batch HTTP/2 upload body flushes#2264
Open
pavel-ptashyts wants to merge 3 commits into
Open
Conversation
pavel-ptashyts
force-pushed
the
perf/http2-upload-flush-batching
branch
from
July 20, 2026 08:50
fa6ab1b to
87d1017
Compare
Avoid flushing every intermediate HTTP/2 DATA chunk produced by Http2BodyWriter. The pump now flushes when it yields for source suspension, when backpressure makes the stream unwritable, or when it writes the terminal DATA frame. This preserves bounded in-flight write behavior while reducing per-chunk flush overhead for multi-chunk uploads. Add a focused unit test for the single terminal flush path while the stream remains writable. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
Flush batching is correct only if every point that parks the body pump flushes already-written DATA frames and can resume without losing the pending chunk. Cover source suspension and persistent channel backpressure in addition to the writable happy path. Correct the new test file's license year to match the repository contribution rules. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
Prevent synchronous writability callbacks from re-entering the HTTP/2 body pump and keep the pump parked until its terminal DATA write completes. Extend the writer test to trigger a nested callback during terminal flush and verify that one endStream frame is written and source cleanup waits for write completion. Codex on behalf of Pavel Ptashyts Co-Authored-By: Codex <codex@openai.com>
pavel-ptashyts
force-pushed
the
perf/http2-upload-flush-batching
branch
from
July 20, 2026 15:08
5e9d2a3 to
531b85e
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
endStreamframesHttp2BodyWriterTestRationale
The HTTP/2 upload body pump previously flushed after every intermediate DATA chunk. That kept writes moving, but it also forced one flush per chunk even when the stream child channel stayed writable. Batching until a yield point preserves bounded in-flight data while reducing flush overhead for multi-chunk uploads.
Netty may synchronously fire
channelWritabilityChangedfromflush(). Explicit pumping and terminal-write states prevent that callback from mutating pump state recursively or emitting a second terminal frame before the first write completes.Validation
./mvnw -pl client -Dtest='org.asynchttpclient.netty.request.body.Http2BodyWriterTest' test(3 tests)./mvnw -pl client -DskipTests compile./mvnw -pl client -Dtest=Http2StreamingBodyFlowControlTest test./mvnw -pl client -Dtest=BasicHttp2Test testAttribution
Codex on behalf of Pavel Ptashyts