envoyproxy / envoyproxy/gateway

Policy CRDs are deep-copied on every reconcile

Open
#9,781 4 comments 0 reactions 1 assignee Claimed by @stillya View on GitHub
area/performance area/translator
Dominant language
Go
Stars
3k
Forks
864
Avg merge
2d 2h
Merged PRs (30d)
140

Description

**Description:**

The k8s provider lists all policy CRDs (`BackendTrafficPolicy`, `ClientTrafficPolicy`, etc) from the cache on every reconcile without `UnsafeDisableDeepCopy`, so controller-runtime deep-copies every policy object each cycle.
I'm bothered by `BTP` mostly because I have about 16k `BTP` objects and with `mergeGateways: true` this becomes a serious hotspot(see attached _flamegraph_)

But thhey can't just be added to the existing `UnsafeDisableDeepCopy` set in `kubernetes.go`
(where all non gateway api already lived), because the provider mutates what it lists(every processor does `policy.Status = gwapiv1.PolicyStatus{}`)

So I propose two steps to fix:

1. Move the `Status` clearing/stripping into a cache `Transform`.
2. Deep-copy the object in the status updater's mutators, this trades deep copy per
*changed* policy for a deep copy of *all* policies per reconcile.

Image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.