-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: memory optimization via enhance informer cache #5683
Feat: memory optimization via enhance informer cache #5683
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #5683 +/- ##
==========================================
- Coverage 61.59% 61.42% -0.18%
==========================================
Files 216 217 +1
Lines 30442 30582 +140
==========================================
+ Hits 18751 18785 +34
- Misses 9976 10080 +104
- Partials 1715 1717 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 10 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
4a4fad3
to
afc5c8c
Compare
pkg/cache/informer.go
Outdated
| } | ||
|
|
||
| // NewClientDisableCacheFor get ClientDisableCacheFor for building controller | ||
| func NewClientDisableCacheFor() []client.Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func NewClientDisableCacheFor() []client.Object { | |
| func Resources2DisableCache() []client.Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is aligned with the naming of controller-runtime manager. See
kubevela/cmd/core/app/server.go
Line 165 in afc5c8c
| ClientDisableCacheFor: cache.NewClientDisableCacheFor(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they're different, the naming is trying to become a sentence:
Client disable cache for "some resources", so the field should be "some resources", not copy-pase the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
538c98c
to
1a4a5e9
Compare
charts/vela-core/values.yaml
Outdated
| enableInMemoryWorkflowContext: false | ||
| disableResourceApplyDoubleCheck: false | ||
| enableResourceTrackerDeleteOnlyTrigger: true | ||
| informerCache: true | ||
| applicationRevisionDefinitionStorage: true | ||
| disableWorkflowContextConfigMapCache: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we provide a new optimize section for these fine-grained cache items?
| disableWorkflowContextConfigMapCache: true | |
| disableCacheItems: | |
| disableWorkflowContextConfigMapCache: false |
BTW, the parameter name is confusion, it's default to disable the cache or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be
| disableWorkflowContextConfigMapCache: true | |
| disableCacheItems: | |
| workflowContextConfigMapCache: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to default enabled featuregate
| @@ -60,6 +62,9 @@ func BuildCache(ctx context.Context, scheme *runtime.Scheme, shardingObjects ... | |||
| return nil, err | |||
| } | |||
| } | |||
| if OptimizeInformerCache && OptimizeApplicationRevisionDefinitionStorage { | |||
| go DefaultDefinitionCache.Get().Start(ctx, c, ApplicationRevisionDefinitionCachePruneDuration) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does all cache using a go routine? can we align with them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. all definition cache use one single goroutine.
a7a2f0a
to
c28b89d
Compare
c28b89d
to
6e42ec2
Compare
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
6e42ec2
to
1eaa863
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of your changes
Apply 3 methods to optimize the memory usage.
managedFieldsandkubectl.kubernetes.io/last-applied-configurationwhen storing Application, ApplicationRevision, ResourceTracker in informer. (This only affect the cache, etcd storage not change)Before Optimization

After Optimization

3k app, 9k apprev, RSS 1.02G(Alloc: 401M, Sys: 897M) -> 739M(Alloc: 203M, Sys: 707M), enhance 25%~30%.
Refactor:
I have:
make reviewableto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR if necessary.How has this code been tested
Special notes for your reviewer