h3: replenish bidi stream credit on stream close#79
Merged
Conversation
ngtcp2 does not auto-extend MAX_STREAMS when a stream closes, so the server must call ngtcp2_conn_extend_max_streams_bidi() itself. Without it every QUIC connection was permanently capped at initial_max_streams_bidi (default 100) request streams: each served fast (TTFB ~4ms), then the connection stalled with the server idle. HttpArena baseline-h3/static-h3 collapsed to ~20 req/s per connection (1277 total at c=64) while frankenphp-trueasync hit 201k on the same client. Call ngtcp2_conn_extend_max_streams_bidi(conn, 1) for each client-initiated bidi stream (id & 3 == 0) in stream_close_cb. A/B at c=64 (-m 32, n=64000): 6400 done in 30s -> 60000 done in 10s. Add test 036 driving 150 sequential streams over one reused QUIC connection; pre-fix it stalls at 100.
Contributor
CoverageTotal lines: 81.21% → 81.41% (+0.19 pp)
|
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.
Problem
HttpArena
baseline-h3/static-h3at c=64 collapsed to ~1277 req/s (≈20 req/s per connection), server idle (CPU 12.7%), 0 packet loss, TTFB ~4ms. Same h2load client drove frankenphp-trueasync to 201k → the bottleneck is our H3 path.Root cause
stream_close_cbclosed the nghttp3 stream but never calledngtcp2_conn_extend_max_streams_bidi(). ngtcp2 does not auto-send MAX_STREAMS on close — the application must. So each QUIC connection was permanently capped atinitial_max_streams_bidi(default 100) bidi request streams; after 100 the client could not open another stream and the connection stalled.Bench arithmetic confirms it:
10496 started = 64 conn × (100 done + 64 in-flight).Fix
Call
ngtcp2_conn_extend_max_streams_bidi(conn, 1)for each client-initiated bidi stream (id & 3 == 0) instream_close_cb.Verification
H3CLIENT_REQUEST_COUNT=150: pre-fixresponse_submittedstalls at 100; post-fix all 150 complete.036-h3-stream-credit-replenish; full H3 suite 36/36 green.