Skip to content

perf(quic): twins stop pooling per downstream connection, QUIC UDP offload on the inbound listener, and the ≤1.5× per-request gate for the flag drop (#1021) - #1034

Merged
bpalermo merged 2 commits into
mainfrom
perf/1021-quic-per-request
Sep 28, 2026

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

1. The fan-out: the per-downstream pool was already off. Workers and endpoints explain it.

The hypothesis in #1021 does not hold at origin/main: connection_pool_per_downstream_connection came off the h2 base in #842, so a twin cloned from that base never carried it. At the pin (Envoy 726d7ac), ClusterManagerImpl::ThreadLocalClusterManagerImpl::ClusterEntry::httpConnPoolImpl builds the pool hash from these inputs:

  • the upstream protocols
  • the downstream and upstream socket options
  • transportSocketFactory().hashKey(...), which for QuicClientTransportSocketFactory is CommonUpstreamTransportSocketFactory::hashKey: SNI override, SAN/ALPN overrides, and the hashable shared filter state, i.e. the source SPIFFE ID
  • the downstream connection, but only behind connectionPoolPerDownstreamConnection()

That hash is per worker (ThreadLocalClusterManagerImpl) and per host. So a twin opens one QUIC connection per (worker the source's app connections landed on) per destination endpoint. It does not open one per app connection. This is the same shape as the h2 path, which is why #1006 also saw 128 h2 connections for svc-3/4. The fleet's ~64 connections per destination are Σ over source nodes of (dialling SAs × Envoy workers × endpoints). k6's 60 VUs per node spread their connections across every worker.

Measured with //test/mtlspool TestQUICTwinUpstreamConnections: 12 keep-alive downstream connections from one source to one destination, 3 rounds each. Connections were counted at the destination (distinct QUIC connections) and in the twin's upstream_cx_total:

twin workers QUIC connections
production 1 1
production 4 4
option forced ON (counterfactual) 1 12

Change: proxy.QUICClusterFrom now pins ConnectionPoolPerDownstreamConnection = false. This way a future change to the base cannot turn every app connection into its own QUIC connection. Per-source isolation still holds because a twin carries exactly one identity. Two pods of the same ServiceAccount share a twin's connections, which is the mesh's identity model (identity = SA) and the partition the h2 pool key has used since #842. The QUIC selection tests (TestQUICSelectionPresentsEachSourceIdentity and the swapped-arms negative control) stay green, and so does e2e/eastwest-quic.sh E2/E5 (each caller's own SPIFFE ID in XFCC).

2. UDP GSO/GRO

What the pin supports:

  • Listener: udp_listener_config.downstream_socket_config.prefer_gro defaults to false for listener sockets (UdpListenerImpl). The QUIC listener already gets UdpGsoBatchWriterFactory automatically when supportsUdpGso() is true (listener_impl.cc). An explicit envoy.udp_packet_writer.gso skips that kernel check.
  • Upstream: QUIC client sockets always set UDP GRO (createConnectionSocket). The only client packet writer (envoy.quic.packet_writer.default) has no GSO, so nothing on the twin can be changed.
  • Kernel: talos 6.18 has UDP_SEGMENT (≥ 4.18) and UDP_GRO (≥ 5.0).

Measured with //test/mtlspool TestQUICRequestCPU (new and opt-in: --test_env=AETHER_QUIC_COST=1). A source Envoy sends through the production twin to a destination Envoy whose QUIC listener carries the variant. CPU is /proc/<pid>/stat utime+stime of both processes, loaded minus idle, reported as ms of CPU per request. 10,000 paced requests at 250 rps over 8 connections, 2 interleaved repetitions:

variant src dst total vs h2
h2 0.569 0.317 0.885 1.00×
h3, automatic writer (GSO), GRO off (old production) 0.942 0.754 1.696 1.92×
h3, explicit default writer (no GSO) 0.946 0.771 1.717 1.94×
h3, explicit GSO writer 0.935 0.751 1.686 1.91×
h3, GRO off 0.935 0.757 1.692 1.91×
h3, GRO on (new production) 0.926 0.675 1.602 1.81×

A sparse run (2,000 requests at 25 rps on one upstream connection, with a 40 ms gap that outlasts the delayed-ACK timer) gave the same result: h2 1.012, h3 without GRO 1.950 (1.93×), h3 with GRO 1.857 (1.83×). Destination CPU went from 0.870 to 0.795 ms.

Result: GSO makes no measurable difference. The three writers are within 1.5 %, because a mesh RPC response is one or two packets. GRO on the listener cuts destination CPU per request by 11 % (dense) and 9 % (sparse), and total CPU by 5 %. Change: proxy.InboundQUICUDPListenerConfig() sets prefer_gro: true and leaves the writer unset, so Envoy keeps choosing GSO automatically.

3. ACK / idle settings: reviewed, not changed

QuicProtocolOptions has no max_ack_delay or ack-frequency field, only QUICHE connection-option tags, and no measurement here supports picking one. The twin's HTTP idle timeout (30 s) already closes idle connections long before QUICHE's 600 s idle_network_timeout. The stream and connection windows limit buffering, not CPU. Http3ProtocolOptions is unchanged.

4. The gate

e2e/soak/README.md gets "The QUIC per-request cost gate (#1021)". It records the #1006 method: matched 80-minute no-roll windows (T0+6h05m→T0+7h25m), per-destination rps matched to ~2 %, envoy-only Pyroscope process_cpu, loaded minus idle, and per_h3 = per_h2 + Δenvoy / quic_rps. Acceptance for #979: h3 ≤ 1.5× h2. The baseline is 3.3×, 2.88 fleet envoy cores (rev242), against the rev239 h2 reference of 3.3 ms per request. It is also added to the Grading list. No load was run against talos-main.

5. //test/envoy_validate

  • The QUIC fixtures still pass envoy --mode validate with prefer_gro.
  • New: TestQUICUpstreamsDoNotPoolPerDownstreamConnection, over the fixture bytes plus an anti-vacuity flip.
  • TestNodeBootstrapCarriesTheQUICInbound now also asserts prefer_gro: true and no pinned writer.
  • Both were seen red: with production flipped (= true in QUICClusterFrom, PreferGro: false), both tests failed with the aether#1021 messages. Both are green again after restoring.

6. Docs

  • 038 Phase 4b: why twins never pool per downstream connection (with the pool-key reading and the 1/4/12 measurement), the offload choices with numbers, the ACK review, and the gate. There is also a one-line summary in the 4b table row.
  • docs/runbook.md: how to read h3 per-request cost, and the expected connection count per destination, which is SAs × workers × endpoints per source node, not app connections. It includes PromQL.

Verification

  • bazel test //agent/... //test/... passes, 38/38.
  • --config=race //agent/internal/xds/... passes.
  • --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/... //test/... is clean. //:format produced no diff.
  • e2e/eastwest-quic.sh on kind passes E0–E5, with images built through the scratchpad output root and EWQ_SKIP_BUILD=1. The proxy log has no GRO requested but not supported line. The kind cluster was deleted and the context restored to talos-main.

What this does not close

On loopback the harness puts h3 at ~1.8× h2 after GRO, and production was 3.3×. GRO alone will not reach 1.5×, and the connection fan-out is the same as h2's (per worker × endpoint), so there is no cheap reduction left there. The ≤ 1.5× gate stays open. It needs a soak reading, and probably work beyond this PR, such as fewer, denser QUIC connections (per-worker pools are Envoy's design) or QUICHE ACK tuning backed by a profile. Hence:

Refs #1021

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 28, 2026 00:21
…fload on the inbound listener, and the ≤1.5× per-request gate for the flag drop (#1021)

- proxy.QUICClusterFrom pins connection_pool_per_downstream_connection off on
  every twin (one identity per twin; the option only multiplies QUIC
  connections by app connections). //test/mtlspool
  TestQUICTwinUpstreamConnections: 12 downstream connections -> 1 QUIC
  connection (1 worker), 4 (4 workers), 12 (option forced on).
- proxy.InboundQUICUDPListenerConfig: prefer_gro on the inbound QUIC listener
  (Envoy defaults it off for listeners); writer left to Envoy's automatic GSO
  selection. TestQUICRequestCPU (opt-in, AETHER_QUIC_COST=1): destination CPU
  per request -11 % dense / -9 % sparse; GSO writer variants within noise.
- //test/envoy_validate: no quic: twin pools per downstream connection; the
  node bootstrap's QUIC inbound carries prefer_gro and no pinned writer (both
  seen red by flipping production).
- Docs: 038 Phase 4b, runbook (per-request cost, connection-count
  expectation), e2e/soak/README.md gate (h3 <= 1.5x h2, baseline 3.3x /
  2.88 fleet envoy cores).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit ed1a194 into main Sep 28, 2026
24 checks passed
@bpalermo
bpalermo deleted the perf/1021-quic-per-request branch September 28, 2026 03:40
bpalermo added a commit that referenced this pull request Sep 28, 2026
Resolves the 038 Selection conflict with #1034 (#1021 per-request cost) by
keeping both paragraphs: #1033's admission rule, then #1021's cost findings.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit that referenced this pull request Sep 28, 2026
…ant-twin-pairs

Keeps both sides: #1034's quic_cost_test.go and 038 per-request-cost
paragraph alongside #1036's quic_dormant_test.go and dormant-pair paragraph.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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