Commit f6bcbbb
⚡ Optimize memory usage with cache transforms and reduced copying
This commit implements several memory optimizations that reduce peak
memory usage during e2e tests by ~7.8% (6.57 MB):
1. Strip managed fields and large annotations from cached objects
- Add DefaultTransform function to cache that removes managed fields
- Remove kubectl.kubernetes.io/last-applied-configuration annotations
- Applied to all objects before storing in informer caches
2. Optimize label copying in revision generation
- Replace maps.Clone with direct allocation and copy
- Pre-allocate maps with correct capacity
- Reduces unnecessary DeepCopy operations by 37%
3. Strip metadata from revision objects
- Remove managed fields and large annotations from objects
- Applied in both Helm and plain manifest processing paths
Memory impact (measured via pprof during test-experimental-e2e):
- Peak memory: 84.58 MB → 78.01 MB (-6.57 MB, -7.8%)
- DeepCopyJSONValue: 17.50 MB → 11 MB (-6.5 MB, -37%)
- Sustained 7-14K reduction per snapshot throughout test execution
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent c4b382b commit f6bcbbb
File tree
2 files changed
+55
-8
lines changed- cmd/operator-controller
- internal/operator-controller/applier
2 files changed
+55
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
| |||
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
689 | 713 | | |
690 | 714 | | |
691 | 715 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
| |||
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| |||
382 | 388 | | |
383 | 389 | | |
384 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
0 commit comments