Repository navigation
Description
Summary
Staged roadmap to improve and test the HTTP/3 data path. Every claim below was verified by reading our code (src/http3/), and the techniques are cross-checked against two reference QUIC servers whose sources are on the bench box: nginx (own QUIC stack) and h2o + quicly.
The work is split into self-contained phases. Each phase delivers: (1) code, (2) tests, (3) a perf measurement against h2o/nginx, and (4) passes the shared exit gate below. Phases are ordered by value/effort; later phases may be deferred without blocking earlier ones.
Where we already are (parity — do NOT re-flag)
Confirmed present in our ngtcp2 + nghttp3 path:
- recvmmsg batch (
HTTP3_LISTENER_RECV_BATCH = 10, outer capH3_DRAIN_BATCH_CAP = 16→ 160 dgram/tick) —src/http3/http3_listener.c:51,372,400. (nginx has no recvmmsg — we are ahead on RX.) - GSO send via
UDP_SEGMENT, 64×1500 = 96 KiB batch, one-way latch-off onEIO/EINVAL—src/http3/http3_io.c:194(drain_out,H3_FLUSH_BATCH),src/http3/http3_listener.c:627(send_gso). - No per-packet malloc — stack scratch buffers (
batch_buf, recvbufs[10][1600]). - Stream slab pool, timer rearm (multishot), lazy errqueue drain, peer cache, ECN cmsg both directions.
- Security: Retry / address validation, stateless reset, version negotiation + GREASE, anti-amplification, per-peer connection budget, header/body caps.
This base is roughly at h2o's I/O level. The phases below close the remaining gaps.
Non-goal: MSG_ZEROCOPY for QUIC datagrams. Both h2o (lib/common/socket.c — TCP only) and nginx deliberately avoid it; page-pin overhead exceeds the win on small datagrams. Remove the stray mention from TODO.md Step 1.
Shared per-phase exit gate (run after EVERY phase)
A phase is not done until all of these pass:
- Code quality review — no dead code, no entry-guard NULL checks on static fns, cleanup blocks separated by blank lines, blank line after closing
}. - Comments — short (1–2 lines max), no multi-paragraph algorithm essays; remove any TODO that the phase resolved.
- C
conststyle —constonly before the type (const T *p,const T x); neverT *const p.conston read-only value params (const bool,const size_t) and on init-and-read locals/read-only pointer params. - Copy audit — count
memcpy/zend_string_init/smart_strcopies on the changed hot path; document each remaining copy and why it is unavoidable. A phase must not add a copy to the per-packet path without justification. - Perf analysis —
strace -csyscall deltas (sendmsg/recvmsg per request) + 3× h2load median (release build only,/home/edmond/php-release/bin/php) for 3 B / 16 K / 1 MB bodies at c=10/100/1000. Compare against h2o and nginx on the same box. No RPS regression vs the pre-phase baseline. - Tests green — full phpt suite (
tests/phpt/server/h3/), fuzz (tests/fuzz/h3_datagram_fuzz.c), and the phase's new tests.
Phase 0 — Baseline & measurement harness
Prerequisite for measuring every later phase.
Code / setup
- Reproducible H3 bench script: our server vs h2o (
~/HttpArena-true-async/frameworks/h2o) vs nginx (~/.../nginx) on the same box, same cert, same payloads. - Wire
quic-interop-runner(~/quic-interop-runner) as a conformance gate against our server. - Capture syscall profile per request (
strace -c: sendmsg/recvmsg/sendmmsg counts).
Done
- Baseline committed (RPS, p50/p99, retransmit rate, sendmsg-per-request) for 3 B / 16 K / 1 MB × c=10/100/1000, alongside h2o + nginx numbers. Same spirit as the coverage baseline.
Phase 1 — Deferred / coalesced output [HIGH value, LOW–MED effort]
Problem (verified). drain_out runs per inbound datagram — src/http3/http3_listener.c:383-467 (poll inner loop) → http3_connection_dispatch → read_pkt → drain_out (src/http3/http3_connection.c:728). GSO coalesces only one drain's output; there is no flush coalescing across the 10/160 datagrams of a tick. (Our finding "H3-3".)
Reference. nginx solves exactly this with a posted push event: every state change (ACK rx, congestion unblock, loss, new stream data) just ngx_post_event(&qc->push,...); one push_handler runs ngx_quic_output once at end-of-iteration (ngx_event_quic.c:1447). It even re-posts push after a new stream becomes readable to coalesce stream data + ACK into one datagram (ngx_event_quic_streams.c:481-494). h2o drains per-connection once per h2o_quic_send (lib/http3/common.c:1335).
Code
- In the
poll_cbinner loop, onlyread_pkt; collect touched connections into a dirty-set. - After the recvmmsg batch, call
drain_outonce per dirty connection. - Keep the existing terminal-check / timer-arm ordering.
Tests
- Ordering correctness under a multi-datagram burst to one connection.
- Regression phpt: response integrity unchanged.
- ACK-coalescing assertion: fewer ACK packets when a response is queued.
Perf vs refs
sendmsg-per-request before/after; target = strictly fewer; expect ngtcp2 to coalesce ACK + response. Compare absolute count to nginx/h2o.
Phase 2 — Pacing aligned to GSO burst [MED / MED]
Problem (verified). No pacing. drain_out ignores ngtcp2_conn_get_send_quantum() and ships the full 96 KiB / 64-packet burst at once. Fine on loopback micro-responses, lossy on real bulk paths.
Reference. quicly: userspace token bucket, burst bounded QUICLY_PACER_BURST_LOW=8 .. HIGH=10 MTU = exactly one GSO sendmsg — pacing and GSO are co-designed (deps/quicly/include/quicly/pacer.h, integrated at deps/quicly/lib/quicly.c:5563). nginx does not pace (window-only) — a path where we can match h2o and beat nginx.
Code
- Read
ngtcp2_conn_get_send_quantum(); cap the GSO batch to the pacing window. - Re-arm the connection timer at
pacer_can_send_atso a paced connection wakes precisely when more credit is available.
Tests
- Under
tc netem(rate + small queue): retransmit rate must drop vs unpaced. - Pacing must not stall a stream (large body completes within deadline).
Perf vs refs
- 1 MB body throughput + retransmit rate vs h2o (paced) and nginx (unpaced) over an emulated bottleneck.
Phase 3 — ACK frequency / delayed-ACK tuning [LOW–MED / LOW]
Problem (verified). No ACK tuning — relying on ngtcp2 defaults. Per-datagram drain (pre-Phase-1) compounds return-path sends.
Reference. h2o: ACK-frequency extension + delayed ACK + packet-tolerance (deps/quicly/lib/quicly.c:1713-1768). nginx: delayed ACK, gap = NGX_QUIC_MAX_ACK_GAP = 2, immediate on reorder (ngx_event_quic_ack.c:1421).
Code
- Advertise
min_ack_delay/ ack-frequency transport params (subject to ngtcp2 version support; document the floor).
Tests
- ACK count per N inbound ack-eliciting packets matches the configured tolerance.
Perf vs refs
- Return-path
sendmsgcount vs h2o / nginx for a streaming-upload workload.
Phase 4 — UDP_GRO on receive [MED / MED — our edge]
Problem / opportunity. Neither h2o nor nginx uses UDP_GRO (h2o: recvmmsg only; nginx: plain recvmsg loop, ngx_event_quic_udp.c:85). Our raw fd (src/http3/http3_listener.c:965, we already setsockopt) supports it — a genuine edge.
Code
setsockopt(UDP_GRO); parse theUDP_GROcmsg to recover segment size; split the coalesced super-buffer and feed each segment toread_pkt.- Keep recvmmsg as the outer batch; GRO reduces syscalls within a batch.
Tests
- GRO on/off response parity.
- Bulk-upload correctness with coalesced inbound segments.
Perf vs refs
recvmsg/recvmmsgcount on a bulk-inbound workload vs h2o/nginx. Honest scope: helps bulk inbound (uploads, ACK bursts), marginal for small request/response.
Phase 5 — Static body copy elimination [LOW / LOW]
Problem (verified). Static pump double-copies: emalloc(buf) once (src/http3/http3_static_response.c:124) then zend_string_init(buf, got, 0) copies every ≤16 KiB chunk (:173). (Our finding "H3-2".)
Code
zend_string_alloc(want)per chunk and read directly intoZSTR_VAL(chunk); drop the intermediatebuf→zend_stringmemcpy.
Tests
- Static file byte-integrity (small / boundary / large).
Perf vs refs
- memcpy/CPU on a large static file; note disk→wire zero-copy (sendfile/splice) is impossible under QUIC encryption — this is the only copy we can remove.
Phase 6 — Real local address / migration [BLOCKED upstream]
Problem (verified). The local sockaddr is fabricated from bind config because zend_async_udp_sockname does not exist — src/http3/http3_connection.c:137-142 ("Step-6 upstream blocker"); the same fake value is reused at accept/dispatch/drain. Consequence: connection migration, path validation, 0-RTT, and PMTU feedback cannot work correctly. (Our finding "H3-1".)
Code
- Land
zend_async_udp_socknamein the async core; thread the real local addr into the ngtcp2 path; enable path validation + migration; feed PMTU/errqueue back into ngtcp2.
Tests
quic-interop-runnermigration + multi-path cases; NAT-rebind.
Perf — n/a (correctness phase).
Phase 7 — eBPF CID steering for multi-worker [FUTURE — depends on Phase 6]
Reference. nginx routes by DCID in-kernel via SO_ATTACH_REUSEPORT_EBPF + BPF_MAP_TYPE_SOCKHASH (ngx_event_quic_bpf.c, bpf/ngx_quic_reuseport_helper.c) so migrated/ rebinding connections stay on their owning worker — eliminating cross-worker handoff. We currently setsockopt(SO_REUSEPORT) only (src/http3/http3_listener.c:981), giving default 4-tuple hashing that breaks under migration.
Scope. Only meaningful once Phase 6 enables migration. Encode worker id in the server CID; attach the reuseport eBPF program.
Test coverage gaps to fill alongside the phases
Existing: tests/phpt/server/h3/ (retry, per-peer budget, idle timeout, headers overflow, conn cleanse, stats, alt-svc, config), tests/h3client/, tests/bench/h3_*, tests/fuzz/h3_datagram_fuzz.c.
Add:
- GSO on/off parity phpt (force
gso_disabled, compare bytes). - Flow-control / backpressure under a slow consumer (mirror the H2 streaming-body tests).
- Version negotiation + stateless reset functional tests (have code, no direct phpt).
- ECN end-to-end assertion.
- Conformance:
quic-interop-runnerin CI as a gate (handshake, transfer, retry, resumption, multiplexing). - Perf regression guard: commit the Phase-0 baseline; each phase updates it with before/after + h2o/nginx columns.
References
Our code: http3_listener.c:383-467,627,965, http3_io.c:194, http3_connection.c:137-142,728, http3_static_response.c:124,173.
nginx: ngx_event_quic_output.c:335 (GSO segments), ngx_event_quic.c:1447 (push handler), ngx_event_quic_streams.c:481-494 (coalesce reorder), ngx_event_quic_udp.c:85 (plain recvmsg), ngx_event_quic_ack.c:1421 (delayed ACK), ngx_event_quic_bpf.c (eBPF steering), ngx_event_quic_openssl_compat.c (why nginx rolled its own QUIC: stock-OpenSSL, zero new deps).
h2o/quicly: lib/http3/common.c:206-224,1335 (GSO + per-conn drain), :787-835 (recvmmsg 10), deps/quicly/include/quicly/pacer.h (8–10 MTU burst), deps/quicly/lib/quicly.c:1713-1768 (ACK), :5563 (pacing integration).
Activity
h3: Phase 0 baseline harness + committed baseline (#59)
h3: defer outbound flush to once-per-tick (coalesce sends) — Phase 1 (#…
h3/bench: QUIC h2load harness + benchmarking notes (#59)
h3: UDP_GRO on receive — split coalesced datagrams — Phase 4 (#59)
h3: add env-gated H3_TRACE lifecycle instrumentation (#59)
h3: guard arm_timer against NULL ngtcp2_conn — fix dirty-list UAF (#59)
h3: per-peer budget opt-in + global cap + explicit refusal (#59)
h3: enlarge UDP socket buffers (SO_RCVBUF/SO_SNDBUF) (#59)
h3: make UDP socket buffer size configurable (#59)
EdmondDantes commentedon May 31, 2026
Closing — staged H3 roadmap done; serving-throughput collapse root-caused & fixed
Shipped
2221508), Phase 1 deferred output / dirty-list (68812fe), Phase 4 UDP_GRO on receive (615ccd4).DEFAULT_HTTP3_PEER_BUDGET 16→0), added a global per-listener cap and an explicitCONNECTION_REFUSEDfor validated clients (vs silent drop → 7 s PTO hang), plus a post-Retry routing fix.4ed421c. → 64/64 accepted.1162c4b). single-worker c=64: ~124 → ~20 000 req/s (×60), 0 errored. No regression across h1/h2/h3/async-db (h1 keep-alive +10%).arm_timerNULL guard,5c43ed2); UDP socket buffers enlarged and exposed viasetHttp3SocketBufferBytes()(83f9c70,2d600ba).Deferred / follow-ups
http3_connection_free— the guard is a partial mitigation).main(canonical php-release needs a rebuild/install to pick it up);SO_RCVBUFneedsnet.core.rmem_maxraised to take effect.Closing as the roadmap's core goal — verified, non-regressing H3 throughput vs nginx/h2o — is met.
Merge pull request #61 from true-async/59-http3-staged-performance-ro…
Merge pull request #68 from true-async/docs-h3-roadmap-status
Merge pull request #70 from true-async/59-h3-pacing-opt-in
Merge pull request #71 from true-async/59-h3-roadmap-fixups
Merge pull request #73 from true-async/59-h3-finish-all
Merge pull request #75 from true-async/59-h3-callbacks-comment-fix