Skip to content

Batch bodyless HEADERS flushes in the H2 downstream write loop - #772

Merged
haga-rak merged 1 commit into
mainfrom
fix/h2-bodyless-header-batching
Aug 7, 2026
Merged

haga-rak merged 1 commit into
mainfrom
fix/h2-bodyless-header-batching

Conversation

@haga-rak

@haga-rak haga-rak commented Aug 7, 2026

Copy link
Copy Markdown
Owner

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.

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.
@haga-rak
haga-rak merged commit b58fafb into main Aug 7, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant