Repository navigation
fix(quic): coalesce twin admissions into one snapshot so a pod's first use of many QUIC destinations fits the on_demand window (#1086) - #1102
Merged
Conversation
…t use of many QUIC destinations fits the on_demand window (#1086) A pod's identity dialling 7-10 QUIC destinations for the first time at once (k6 loader start) produced 66-141 x 503 NC cluster_not_found per soak. Every admitted `quic:` pair started its own goroutine running a full generateSnapshot. They serialized on snapshotMu; the first already carried every pair recorded so far, so the rest rebuilt and re-set the same snapshot one after another. On talos each build is ~93% go-control-plane version-map hashing (proto marshal + sha256 of every resource) inside SetSnapshot, under the cache mutex, on an agent capped at 200m: 200-870 ms of wall clock each. The ADS stream goroutine needs that same mutex for every request it handles, so both the later ODCDS requests (received 0.47-0.9 s late) and the new twins' EDS subscriptions (Envoy cannot warm the cluster without them) queued behind the redundant builds. On main-worker-05, 2026-10-01T00:36:28-31Z: six admissions, eight snapshot builds in 4.4 s, and four twins whose CDS add landed at 30.14-30.22Z were still warming when their on_demand timeouts fired at 30.645-30.738Z. requestQUICPublish keeps at most one publish pending and one running: the first admission of a burst waits 10 ms for the rest, then builds once; an admission that arrives during the build forces exactly one more build. N simultaneous admissions now cost 1-2 builds instead of N. Only the publish is coalesced: recordQUICPair still records, confirms and persists the pair synchronously, so the strand rule, the cert gate, demand_confirmed and the stream-reset classification are untouched. ResumeQUICSubscriptions rides the same publisher. Proof: TestQUICAdmissionBurstCoalesces (10 simultaneous admissions, <= 2 builds) is red on main (10 builds) and green here (1). e2e/eastwest-quic.sh gains E7, a new ServiceAccount's first use of 10 QUIC destinations x 5 concurrent requests: on kind, main 10 builds per burst and first-use p99 0.93-1.56 s; this change 1-2 builds and p99 0.22-0.55 s, 0 non-200 on both (kind never crossed 2 s on main). Closes #1086 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
Closes #1086
What was failing
When a pod's identity dials 7–10 QUIC destinations for the first time at once (the k6 loader start), some requests fail with
503 NC cluster_not_found. This happened on three soaks: 116, 141 and 66 failures.Timeline: main-worker-05, 2026-10-01T00:36Z (51 of the 66)
Sources: Envoy
cm odcdsandcds:lines, agent lines, access-logstart_time, and Pyroscope for the agent.quic:…@aether-test/default.SetSnapshotplus identity logging.SetSnapshotholding the cache mutex.SetSnapshotalone took about 600 ms.cm odcds: on-demand discovery … timed outfires for svc-1, echo, mixed-svc and svc-4. Every request waiting on those twins (including ones that joined late) gets 503 NC.main-worker-02 (the other 15 failures) shows the same pattern. svc-4 was requested at 28.144, but the agent only admitted it at 29.046, 0.9 s later, after four back-to-back builds. Its twin reached Envoy at 30.78, after the 30.144 timeout.
Where the time goes
ObserveQUICTwinandResumeQUICSubscriptionseach started their owngo generateSnapshot(). These serialize onsnapshotMu. The first one already includes every pair recorded so far, because admission records the pair synchronously, so the rest are redundant.generateSnapshotCPU in go-control-plane'srespondDeltaWatches→ConstructVersionMap(deterministic proto marshal plus sha256 of every resource). That runs insideSetSnapshotundercache.mu. The agent is capped at 200m CPU, so a build takes 200–870 ms of wall clock.cache.mufor every request (watch cancel plusCreateDeltaWatch). Redundant builds therefore delay both the arrival of later ODCDS requests and the EDS subscriptions a new twin needs before it can warm.on_demandtimeout. Raising it is not justified: the measured cost is the redundant work, not a one-off setup delay.Fix
requestQUICPublish/runQUICPublisherinagent/internal/xds/cache/quicpublish.go:ResumeQUICSubscriptions(re-subscriptions on a fresh stream) uses the same publisher.Only the publish is coalesced.
recordQUICPairstill runs synchronously on the ODCDS request: it records the pair, confirms it (demand_confirmed, #1073/#1076), records the ledger subscription and persists it. The invariants are unchanged:The
on_demandtimeout is unchanged.Evidence
Unit test, red then green
TestQUICAdmissionBurstCoalesces: 10 simultaneous first-use admissions must cost ≤ 2 builds, and every twin must be published with its CLA in under 500 ms. The test file builds against main.BenchmarkQUICAdmissionBurst, under asystemd-run -p CPUQuota=20%scope (the agent's 200m cap):Also added in
quicpublish_test.go:kind, red then green
New leg E7 in
e2e/eastwest-quic.sh(burstsubcommand, also part ofverify): a brand-new ServiceAccount sends 10 QUIC destinations × 5 concurrent requests the instant its app starts, with the identity gate on. It asserts 0 non-200 and reports p50/p99/max latency, admissions, coalesced publishes and snapshot builds (builds needEWQ_DEBUG=1).Cluster
aether-1086, same cluster for both. The agent image was swapped between main and the fix, each run used a fresh SA, and every row is a separate run:verify)kind never crossed the 2 s timeout on main, so there is no NC red here. The red is the build count (one per admission) and a 4–5× higher first-use p99. The full
verify(E0–E7) is green with the fix.Other checks:
bazel test //agent/internal/xds/...,--config=raceonagent/internal/xds/cacheandagent/internal/xds/server,make gazelle,make format, andbazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...all pass. Nocharts/change.Open risks / follow-ups
ConstructVersionMapis about 93% of build CPU. This is only safe if published protos are never mutated in place.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr