Skip to content

making MergeEnv perform better for large envs - #1114

Open
augustoribeiro wants to merge 1 commit into
cloudnative-pg:mainfrom
augustoribeiro:ari/mergeenv_optimization
Open

augustoribeiro wants to merge 1 commit into
cloudnative-pg:mainfrom
augustoribeiro:ari/mergeenv_optimization

Conversation

@augustoribeiro

@augustoribeiro augustoribeiro commented Sep 23, 2026 •

Copy link
Copy Markdown

The MergeEnv performs very poorly (O(n^2)) if the environment is very large (20k items). We faced this problem because we have a large amount of pods in the namespace. The problem likely be fixed by setting enableServiceLinks: false but still sounds like a good idea to improve this function.

Here's the isolated MergeEnv benchmark.

goos: darwin   goarch: arm64   cpu: Apple M1 Pro
services env vars original new speedup
250 2,007 4.9 ms 0.14 ms 36×
1,000 8,007 73.6 ms 0.73 ms 100×
3,000 24,007 655.9 ms 1.52 ms 432×

Allocations per call:

services original new
250 2,008 10
1,000 8,008 34
3,000 24,008 66

@augustoribeiro
augustoribeiro requested a review from a team as a code owner September 23, 2026 11:28

This branch has not been deployed

No deployments
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.

1 participant