Skip to content

agent: one snapshot build costs 200–870 ms under the cache mutex on a 200m-CPU agent (93% is go-control-plane version-map hashing) — it blocks the ADS stream and still fails a first-use burst if a single build is slow #1105

Closed

Description

@bpalermo

Found while fixing #1086 (PR #1102, which coalesces twin admissions so a burst costs one build instead of N).

Measured on main-worker-05 (2026-10-01T00:36Z) and in Pyroscope: ~93% of a generateSnapshot()/SetSnapshot cycle is go-control-plane's ConstructVersionMap hashing every resource, executed while holding the snapshot-cache mutex, on an agent limited to 200m CPU. One build therefore takes 200–870 ms of wall clock, and the ADS stream goroutine needs the same mutex for every request it handles — so any build delays ODCDS answers and EDS subscriptions for the new twins. With #1102 a burst is one build, but if that single build exceeds ~1.5 s the 2 s on_demand timeout still fires (kind with ~50 pods on one 200m agent showed 2–11 s builds). Registry-refresh builds also still compete with a burst.

Levers (pick after measuring):

  1. Memoize per-resource version hashes across snapshots (safe only if published protos are never mutated in place — audit that), so an unchanged resource is not re-hashed.
  2. Revisit the agent's CPU limit (200m) / make it a request without a limit, since the cost is bursty and latency-critical.
  3. Build outside the mutex and swap.

Gate: p99 snapshot build time on a 50-pod node < 200 ms; BenchmarkQUICAdmissionBurst and the E7 burst leg in e2e/eastwest-quic.sh as regression checks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions