Skip to content

perf: use UnsafeDisableDeepCopy and cache for list Unstructured Resources#7704

Merged
arkodg merged 2 commits intoenvoyproxy:mainfrom
fabian4:disable_deepcopy
Jan 14, 2026
Merged

perf: use UnsafeDisableDeepCopy and cache for list Unstructured Resources#7704
arkodg merged 2 commits intoenvoyproxy:mainfrom
fabian4:disable_deepcopy

Conversation

@fabian4
Copy link
Copy Markdown
Contributor

@fabian4 fabian4 commented Dec 9, 2025

What type of PR is this?

perf: use UnsafeDisableDeepCopy and cache for list Unstructured Resources

What this PR does / why we need it:

use UnsafeDisableDeepCopy and cache for list Unstructured Resources

Which issue(s) this PR fixes:

Fixes #7626

Release Notes: Yes/No

@fabian4 fabian4 requested a review from a team as a code owner December 9, 2025 11:30
@@ -75,6 +76,11 @@ func New(ctx context.Context, restCfg *rest.Config, svrCfg *ec.Server, resources
HealthProbeBindAddress: healthProbeBindAddress,
LeaderElectionID: "5b9825d2.gateway.envoyproxy.io",
LeaderElectionNamespace: svrCfg.ControllerNamespace,
Client: client.Options{
Copy link
Copy Markdown
Contributor

@arkodg arkodg Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this section needed ? or can be do with only L155-157

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should set the value to true to cache the unstructured resources here

@fabian4 fabian4 force-pushed the disable_deepcopy branch 2 times, most recently from 1bd6fbb to 5ee3e68 Compare December 13, 2025 05:15
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.82%. Comparing base (a2702cc) to head (4efefc6).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7704      +/-   ##
==========================================
- Coverage   72.82%   72.82%   -0.01%     
==========================================
  Files         235      235              
  Lines       35214    35219       +5     
==========================================
+ Hits        25645    25648       +3     
- Misses       7752     7754       +2     
  Partials     1817     1817              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fabian4 fabian4 force-pushed the disable_deepcopy branch 3 times, most recently from befe485 to 378f26f Compare December 13, 2025 10:00
@fabian4 fabian4 requested a review from arkodg December 13, 2025 12:22
@fabian4 fabian4 force-pushed the disable_deepcopy branch 2 times, most recently from ec1f7c2 to 01216af Compare December 22, 2025 07:41
@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Dec 26, 2025

@fabian4 can this be scoped to only unstructured

@aponysus
Copy link
Copy Markdown
Contributor

Heads up: #7626 also calls for updating the unstructured List() in internal/provider/kubernetes/filters.go to use client.UnsafeDisableDeepCopy. I don’t see that in this PR.

I have a small, tested diff for filters.go (and a safe way to enable CacheOptions.Unstructured=true without overwriting existing cache settings). Happy to open a PR against this branch or drop a commit you can cherry-pick.

@fabian4
Copy link
Copy Markdown
Contributor Author

fabian4 commented Dec 27, 2025

I tried enable UnsafeDisableDeepCopy at the cache level but cache configuration requires explicit GVK registration.

// Supported Gateway API GVKs
// controller-runtime cache requires concrete GVKs.
// Unstructured caching is enabled per GVK using unstructured.Unstructured
gatewayAPIGVKs = []schema.GroupVersionKind{
	{Group: "gateway.networking.k8s.io", Version: "v1beta1", Kind: "Gateway"},
}

for _, gvk := range gatewayAPIGVKs {
	u := &unstructured.Unstructured{}
	u.SetGroupVersionKind(gvk)
	mgrOpts.Cache.ByObject[u] = cache.ByObject{
	UnsafeDisableDeepCopy: ptr.To(true),
	}
}

So maybe we enable it at each List() call is better. Thanks @aponysus

@arkodg arkodg requested review from a team January 11, 2026 05:36
@arkodg arkodg added this to the v1.7.0-rc.1 Release milestone Jan 11, 2026
@arkodg arkodg requested a review from guydc January 11, 2026 05:36
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 11, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 4efefc6
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6966ffaff84f4d000888dac9
😎 Deploy Preview https://deploy-preview-7704--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

…Resources

Signed-off-by: fabian4 <fabian.v.bao@gmail.com>
…Resources

Signed-off-by: fabian4 <fabian.v.bao@gmail.com>
@arkodg arkodg merged commit 80ed3e0 into envoyproxy:main Jan 14, 2026
57 of 59 checks passed
@fabian4 fabian4 deleted the disable_deepcopy branch January 14, 2026 05:33
andreik-n2 pushed a commit to andreik-n2/gateway that referenced this pull request Jan 15, 2026
…rces (envoyproxy#7704)

* Performanceuse UnsafeDisableDeepCopy and cache for list Unstructured Resources
Signed-off-by: fabian4 <fabian.v.bao@gmail.com>
SadmiB pushed a commit to SadmiB/gateway that referenced this pull request Jan 30, 2026
…rces (envoyproxy#7704)

* Performanceuse UnsafeDisableDeepCopy and cache for list Unstructured Resources
Signed-off-by: fabian4 <fabian.v.bao@gmail.com>
Signed-off-by: Sadmi Bouhafs <sadmibouhafs@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: use UnsafeDisableDeepCopy and cache for list Unstructured Resources (Extension Server)

4 participants