Repository navigation
perf(xds): precompute GAMMA route domains and effective routes at write time (#540) - #551
Merged
Merged
Conversation
…te time (#540) Two per-snapshot recomputations of write-time-stable data in the xDS cache are now memoized on generation counters (the #549 depGen idiom): - serviceRoutesSnapshot: the effective (local ∪ imported) GAMMA rules with unavailable extension filters stripped were merged + strip-scanned (and copied) on EVERY snapshot. Now memoized on depGen; SetServiceRoutes / SetImportedServiceRoutes invalidate via their existing bump, and SetAuthzSidecar bumps too since authz availability changes the strip result. - routeTargetDomains: the cap_http host-match domain lists were rebuilt via fmt.Sprintf in nested loops (base names × ports) per route target on every snapshot. Now precomputed into a routeDomains memo keyed on depGen (routes + routeTargetPorts) and a new captureAuthGen (captureAuthorities → the SA-backed fqdn source); captureVhosts reads the memo through serviceRoutesAndDomainsSnapshot, which hands back routes + domains from the same generation. Behavior is byte-identical: the per-target domain algorithm is unchanged (same domains, same order), the bare-name uniqueness guard counts over the same set (every effective route target is unconditionally in the dependency set), and strip semantics are untouched. No ordering semantics changed — map iteration nondeterminism in vhost emission is pre-existing and unaffected (lookups only; no ordering is derived from the cached maps). Cached maps follow the depSet convention: shared, replaced never mutated. Fixes #540 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
This was referenced Jul 19, 2026
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.
Fixes #540
Two per-snapshot recomputations of write-time-stable data in
agent/internal/xds/cacheare now memoized on generation counters, following the #549 depGen idiom (no third caching pattern introduced).1. Effective (stripped) GAMMA routes —
gamma.goserviceRoutesSnapshot()used to merge local ∪ imported routes, scan every rule for unavailable extension filters, and copy the whole map on every snapshot. It now returnseffectiveStrippedRoutesLocked(), a memo keyed ondepGen:SetServiceRoutes/SetImportedServiceRoutesalready bumpdepGen;SetAuthzSidecarnow bumps too, since authz availability changes the strip result (boot-time in production, but the memo is never served across the flip).2. Route-target cap_http domains —
capture.gorouteTargetDomains()rebuilt every domain list viafmt.Sprintfin nested loops (base names × ports) per route target on every snapshot. The lists are now precomputed into arouteDomainsmemo (buildRouteTargetDomains), keyed on two input generations:depGen— covers routes androuteTargetPorts(both writers already bump);captureAuthGen— bumped bySetCaptureAuthoritieson content change (the SA-backed fqdn source).captureVhostsreads it throughserviceRoutesAndDomainsSnapshot(), which returns routes + domains from the same generation, so the two can never disagree within one snapshot.routeTargetPortsSnapshot(whose only caller was this path) is removed;routeTargetDomainsbecomes a pure free function called only from the memo rebuild.Behavior equivalence
dependencySetLocked), so counting over all route keys is provably identical (documented onbuildRouteTargetDomains).depSetconvention — shared with callers, documented read-only, replaced (never mutated) on rebuild. All consumers were audited to be read-only.snapshotMuand the unified-snapshot model are untouched.Tests
route_memo_test.go:SetServiceRoutes,SetImportedServiceRoutes,SetAuthzSidecar,SetRouteTargetPorts,SetCaptureAuthorities), plus content-equal authority replacement does not invalidate.dependencies_memo_test.go).Existing
capture_test.go/chain_seam_test.govhost-domain assertions pass unchanged, which independently confirms end-to-end equivalence.bazel test //agent/...green (23/23);//agent/internal/xds/cache:cache_testgreen with--@rules_go//go/config:race=true;make gazelle+make formatapplied.🤖 Generated with Claude Code
https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR