Skip to content

fix: improve perf by switching parentUIDToChildren to map of sets (#26863)#26864

Draft
jcogilvie wants to merge 1 commit intoargoproj:masterfrom
Sanyaku:fix-xns-perf-regression
Draft

fix: improve perf by switching parentUIDToChildren to map of sets (#26863)#26864
jcogilvie wants to merge 1 commit intoargoproj:masterfrom
Sanyaku:fix-xns-perf-regression

Conversation

@jcogilvie
Copy link
Contributor

@jcogilvie jcogilvie commented Mar 17, 2026

Fixes #26863.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@bunnyshell
Copy link

bunnyshell bot commented Mar 17, 2026

✅ Preview Environment deployed on Bunnyshell

Component Endpoints
argocd https://argocd-h5ztid.bunnyenv.com/
argocd-ttyd https://argocd-web-cli-h5ztid.bunnyenv.com/

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@jcogilvie jcogilvie changed the title fix: improve perf by switching parentuidtochildren to map of maps fix: improve perf by switching parentuidtochildren to map of maps (#26863) Mar 17, 2026
@jcogilvie jcogilvie changed the title fix: improve perf by switching parentuidtochildren to map of maps (#26863) fix: improve perf by switching parentUIDToChildren to map of maps (#26863) Mar 17, 2026
@jcogilvie jcogilvie changed the title fix: improve perf by switching parentUIDToChildren to map of maps (#26863) fix: improve perf by switching parentUIDToChildren to map of sets (#26863) Mar 17, 2026
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.03%. Comparing base (63a009e) to head (71ecf42).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
gitops-engine/pkg/cache/cluster.go 83.33% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26864      +/-   ##
==========================================
- Coverage   63.04%   63.03%   -0.01%     
==========================================
  Files         414      414              
  Lines       56286    56284       -2     
==========================================
- Hits        35484    35481       -3     
- Misses      17427    17430       +3     
+ Partials     3375     3373       -2     

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

@jcogilvie
Copy link
Contributor Author

jcogilvie commented Mar 17, 2026

Benchmark Results

Add/Remove Operations (constant time regardless of children count)

Children per Parent Time (ns/op) Allocations
10 66.54 0
50 66.69 0
100 70.88 0
500 66.46 0
1000 78.54 0

Comparison with Previous Implementation

Children Old (slice, O(k)) New (set, O(1)) Speedup
10 ~115 ns 67 ns 1.7×
50 ~329 ns 67 ns
100 ~581 ns 71 ns
500 ~2,600 ns 66 ns 39×
1000 ~5,100 ns 79 ns 65×

Memory Impact

Children per parent Slice Set Overhead
10 664B 848B +28%
100 6.4KB 8KB +25%

Cluster-level estimate (1,000 parent resources, average 10 children each = 10,000 parent-child relationships):

  • Slice-based: ~66KB
  • Set-based: ~85KB
  • Additional overhead: ~18KB

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.

Application Controller Performance regression in 3.3.X

1 participant