-
Notifications
You must be signed in to change notification settings - Fork 606
rm DeepCopy from Status Updator #6986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Contributor
arkodg
commented
Sep 16, 2025
- Use Shallow Copy for TypedMeta, ObjectMeta and Spec which are read only fields during the status update
* Use Shallow Copy for TypedMeta, ObjectMeta and Spec which are read only fields during the status update Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6986 +/- ##
==========================================
- Coverage 71.06% 71.02% -0.05%
==========================================
Files 226 226
Lines 40136 40204 +68
==========================================
+ Hits 28523 28553 +30
- Misses 9925 9970 +45
+ Partials 1688 1681 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jukie
approved these changes
Sep 16, 2025
kkk777-7
approved these changes
Sep 17, 2025
zirain
pushed a commit
to zirain/gateway
that referenced
this pull request
Oct 1, 2025
* Use Shallow Copy for TypedMeta, ObjectMeta and Spec which are read only fields during the status update Signed-off-by: Arko Dasgupta <arko@tetrate.io>
zirain
pushed a commit
to zirain/gateway
that referenced
this pull request
Oct 1, 2025
* Use Shallow Copy for TypedMeta, ObjectMeta and Spec which are read only fields during the status update Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com>
33 tasks
zirain
added a commit
that referenced
this pull request
Oct 3, 2025
* rm DeepCopy from Status Updator (#6986) * Use Shallow Copy for TypedMeta, ObjectMeta and Spec which are read only fields during the status update Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: avoid string concatenation overhead of fmt.Sprintf in Sort (#6987) ~14% improvement in CPU ``` benchstat old.txt new.txt goos: darwin goarch: amd64 pkg: github.com/envoyproxy/gateway/test/gobench cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ GatewayAPItoXDS/small-12 4.257m ± ∞ ¹ 2.707m ± ∞ ¹ ~ (p=0.700 n=3) ² GatewayAPItoXDS/medium-12 37.32m ± ∞ ¹ 34.76m ± ∞ ¹ ~ (p=1.000 n=3) ² GatewayAPItoXDS/large-12 409.5m ± ∞ ¹ 437.1m ± ∞ ¹ ~ (p=1.000 n=3) ² geomean 40.22m 34.52m -14.17% ¹ need >= 6 samples for confidence interval at level 0.95 ² need >= 4 samples to detect a difference at alpha level 0.05 │ old.txt │ new.txt │ │ B/op │ B/op vs base │ GatewayAPItoXDS/small-12 721.7Ki ± ∞ ¹ 722.4Ki ± ∞ ¹ ~ (p=0.700 n=3) ² GatewayAPItoXDS/medium-12 15.63Mi ± ∞ ¹ 15.63Mi ± ∞ ¹ ~ (p=0.100 n=3) ² GatewayAPItoXDS/large-12 151.3Mi ± ∞ ¹ 151.3Mi ± ∞ ¹ ~ (p=1.000 n=3) ² geomean 11.86Mi 11.86Mi +0.04% ¹ need >= 6 samples for confidence interval at level 0.95 ² need >= 4 samples to detect a difference at alpha level 0.05 │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ GatewayAPItoXDS/small-12 11.70k ± ∞ ¹ 11.71k ± ∞ ¹ ~ (p=0.700 n=3) ² GatewayAPItoXDS/medium-12 257.3k ± ∞ ¹ 257.3k ± ∞ ¹ ~ (p=0.700 n=3) ² GatewayAPItoXDS/large-12 2.467M ± ∞ ¹ 2.467M ± ∞ ¹ ~ (p=0.200 n=3) ² geomean 195.1k 195.2k +0.03% ``` Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: improve mem allocation in TruncatePolicyAncestors (#6998) * perf: improve mem allocation in TruncatePolicyAncestors Relates to #6919 Signed-off-by: Arko Dasgupta <arko@tetrate.io> * lint Signed-off-by: Arko Dasgupta <arko@tetrate.io> * also sort on ns before name Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: reuse route rule metadata (#7001) * perf: reuse route rule metadata * build it once and pass it in the caller * also since EG annotations are rare, make sure to return early and reduce allocations Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: reduce mem allocs in internal/metrics (#7004) ``` │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ MergeLabelValuesOld-12 354.6n ± 42% MergeLabelValuesNew-12 131.6n ± 18% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ MergeLabelValuesOld-12 640.0 ± 0% MergeLabelValuesNew-12 320.0 ± 0% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ MergeLabelValuesOld-12 2.000 ± 0% MergeLabelValuesNew-12 1.000 ± 0% ``` Signed-off-by: Arko Dasgupta <arko@tetrate.io> Co-authored-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: aggregate publish metric counts and call once (#7005) * Reduces calls from O(N) where N is the total number of resources to O(1) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: avoid loop variable in k8s provider (#7010) * reduces heap allocs * also removes the copyloopvar lint error Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: remove reflect from BackendRefContext (#7015) * similar to #6820 ``` BenchmarkBackendRefContext_Old_HTTPBackendRef-12 5002508 239.5 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_HTTPBackendRef-12 4764154 264.1 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_HTTPBackendRef-12 4866708 238.6 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_HTTPBackendRef-12 5032014 243.8 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_HTTPBackendRef-12 4935594 259.5 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_GRPCBackendRef-12 4833061 245.3 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_GRPCBackendRef-12 4970496 252.1 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_GRPCBackendRef-12 4517140 253.2 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_GRPCBackendRef-12 4556660 273.4 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_Old_GRPCBackendRef-12 5003169 244.2 ns/op 152 B/op 3 allocs/op BenchmarkBackendRefContext_New_HTTPBackendRef-12 1000000000 0.2556 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_HTTPBackendRef-12 1000000000 0.2495 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_HTTPBackendRef-12 1000000000 0.2499 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_HTTPBackendRef-12 1000000000 0.2576 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_HTTPBackendRef-12 1000000000 0.2556 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_GRPCBackendRef-12 1000000000 0.2505 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_GRPCBackendRef-12 1000000000 0.2504 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_GRPCBackendRef-12 1000000000 0.2591 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_GRPCBackendRef-12 1000000000 0.2502 ns/op 0 B/op 0 allocs/op BenchmarkBackendRefContext_New_GRPCBackendRef-12 1000000000 0.2483 ns/op 0 B/op 0 allocs/op ``` Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * rm reflect from gateway api runner (#7012) * use length check instead of a relfect `ValueOf(backend.Status).IsZero()` check Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: lazy allocation for new condition in SetConditionForPolicyAncestor (#6999) * only create a new condition when we need to i.e. when it doesnt already exist Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * Fix weighted cluster generation in RouteAction when URLRewrite filter is applied (#7027) * Fix weighted cluster generation in RouteAction when URLRewrite filter is applied Signed-off-by: Sekar Saravanan <sekar.saravanan@jiostar.com> * XDS translator test added - Fix weighted cluster generation in RouteAction when URLRewrite filter is applied Signed-off-by: Sekar Saravanan <sekar.saravanan@jiostar.com> --------- Signed-off-by: Sekar Saravanan <sekar.saravanan@jiostar.com> Signed-off-by: zirain <zirain2009@gmail.com> * fix: use SDS for service account token in Gateway Namespace Mode (#7002) * use sds config for credential injector Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * check for token review status error Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> * use sds config for credential injector Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: reduce ancestorRef copies in policy status (#7032) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: preallocate structs in securitypolicy processing (#7039) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: remove reflect.DeepCopy in parentRef comparison (#7040) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * fix: escape regex metacharacters from path prefix string (#7024) Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: convert mockData into string and reuse in lua (#7078) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Co-authored-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: make sets when needed in policy processing (#7076) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: preallocate slices in route processing (#7041) * perf: preallocate slices in route processing Signed-off-by: Arko Dasgupta <arko@tetrate.io> * use index Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: enable gocritic perfomance linter setting (#7056) https://go-critic.com/overview#checkers-from-the-performance-group Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: avoid JSON Marshal when debug logger is disabled (#7066) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: avoid YAML to JSON conversion in JSONPatch (#7069) * Use value.Raw directly Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * Fix: Preserve route parent status for multi-parent routes (#7068) * fix: preserve route parent statuses during merge Routes with multiple parent references should maintain status for all parents, not just the one being currently updated. The mergeRouteParentStatus function was incorrectly removing parent statuses when they weren't in the current update batch. This change preserves all existing parent statuses during the merge operation, ensuring routes with multiple parents maintain status for all parent refs. Fixes #7067 Signed-off-by: rajsinghtech <rajsinghcpre@gmail.com> Signed-off-by: Raj Singh <raj@tailscale.com> * fix: remove unused controllerName parameter and update tests - Remove unused controllerName parameter from mergeRouteParentStatus function - Update test expectations to match the new behavior where all parent statuses are preserved during merge operations - This ensures routes with multiple parent references maintain status for all parents, not just the ones being currently updated Signed-off-by: rajsinghtech <rajsinghcpre@gmail.com> Signed-off-by: Raj Singh <raj@tailscale.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: remove watchable LoadAll() from gateway api runner (#7081) * perf: remove watchable LoadAll() from gateway api runner * use a keyCache in the gateway-api runner instead of making an expensive LoadAll() call thats copies all the statuses and IRs on every subscribe adding a ton of pressure for GC * use the same mark and sweep operation to clean up the key cache and watchable store * make a one time LoadAll() call in runner Start() to populate the cache for the restart runner case (when EnvoyGateway config is updated) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix tests Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix test Signed-off-by: Arko Dasgupta <arko@tetrate.io> * rm populateCache, not needed since we restart runners and reset watchable messages https://github.com/envoyproxy/gateway/blob/d973842ea2f948a7d6eb2163e8ecc6950b49ae3d/internal/cmd/server.go#L65 Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: enable prealloc linter (#7055) * perf: enable prealloc linter * and fix all the warnings Fixes: #7053 Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: pre allocate maps in btp processing (#7050) Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * perf: fix possible memory leak in XDS snapshot (#7101) perf: fix possible mem leak in XDS snapshot Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> * perf: direct assign policies in translate result instead of append (#7077) * perf: direct assign policies in translate result instead of append Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix test Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * remove redundant file Signed-off-by: zirain <zirain2009@gmail.com> * fix: do not add same service multiple times (#7119) Signed-off-by: zirain <zirain2009@gmail.com> * fix: use maps for backendRefMappings instead of Sets (#7120) * fix: use maps for backendRefMappings instead of Sets * Sets compare by value and BackendRef contain multiple ptrs to Kind, Group and Namespace, so this Set didnt really serve us any good purpose of deduping same backendRefs * Instead use maps keyed by a util string - NamespaceNameWithGroupKind similar to what we use for ExtentionRefFilters Signed-off-by: Arko Dasgupta <arko@tetrate.io> * make key a ptr Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix test Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * bug: disable x-envoy-ratelimited by default (#7110) * bug: disable x-envoy-ratelimited by default * can be enabled with `enableEnvoyHeaders` in CTP Relates to #7034 Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix tests and release note Signed-off-by: Arko Dasgupta <arko@tetrate.io> * fix testdata Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> * fix: use lock when accessing mergeGateways Set (#7124) * fix: use lock when accessing mergeGateways Set * accessed in multiple goroutines to map proxy fleet to resource via labels Fixes this panic ``` fatal error: concurrent map read and map write 4 internal/runtime/maps.fatal({0x3b83570?, 0x8b3de58?}) 5 /opt/hostedtoolcache/go/1.24.7/x64/src/runtime/panic.go:1058 +0x18 6 k8s.io/apimachinery/pkg/util/sets.Set[...[].Has(...) 7 /home/runner/go/pkg/mod/k8s.io/apimachinery@v0.33.3/pkg/util/sets/set.go:78 8 github.com/envoyproxy/gateway/internal/provider/kubernetes.(*gatewayAPIReconciler).envoyObjectForGateway.func1({0x8bc2dc8, 0xc0054163f0}) 9 /home/runner/work/gateway/gateway/internal/provider/kubernetes/predicates.go:666 +0x7b 10 github.com/envoyproxy/gateway/internal/provider/kubernetes.(*gatewayAPIReconciler).envoyObjectForGateway(0xc0018858e8?, {0x8ba6648?, 0xc0009c8b90?}, 0x11?) 11 /home/runner/work/gateway/gateway/internal/provider/kubernetes/predicates.go:682 +0x5e 12 github.com/envoyproxy/gateway/internal/provider/kubernetes.(*gatewayAPIReconciler).updateStatusForGateway(0xc000516600, {0x8ba6648, 0xc0009c8b90}, 0xc00541a380) 13 /home/runner/work/gateway/gateway/internal/provider/kubernetes/status.go:579 +0x5a 14 github.com/envoyproxy/gateway/internal/provider/kubernetes.(*gatewayAPIReconciler).subscribeAndUpdateStatus.func2.1({{{0xc0096a7e46, 0x7}, {0xc001944cc0, 0x11}}, 0x0, 0xc0052fa690}, 0xc00a582a1 0) ``` Relates to #7115 (comment) Signed-off-by: Arko Dasgupta <arko@tetrate.io> * lint Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com> Signed-off-by: Sekar Saravanan <sekar.saravanan@jiostar.com> Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Signed-off-by: rajsinghtech <rajsinghcpre@gmail.com> Signed-off-by: Raj Singh <raj@tailscale.com> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> Co-authored-by: Rudrakh Panigrahi <rudrakh97@gmail.com> Co-authored-by: sekar-saravanan <110888783+sekar-saravanan@users.noreply.github.com> Co-authored-by: Karol Szwaj <karol.szwaj@gmail.com> Co-authored-by: Raj Singh <rajsinghcpre@gmail.com>
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.