-
Notifications
You must be signed in to change notification settings - Fork 757
optimize: preserving needed fields for memory efficiency #1738
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Welcome @Colvin-Y! |
|
Hi @Colvin-Y. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
pkg/descheduler/descheduler.go
Outdated
|
|
||
| func newDescheduler(ctx context.Context, rs *options.DeschedulerServer, deschedulerPolicy *api.DeschedulerPolicy, evictionPolicyGroupVersion string, eventRecorder events.EventRecorder, sharedInformerFactory, namespacedSharedInformerFactory informers.SharedInformerFactory) (*descheduler, error) { | ||
| podInformer := sharedInformerFactory.Core().V1().Pods().Informer() | ||
| podInformer.SetTransform(preserveNeeded) |
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.
Using SetTransform seems to be very helpful for memory optimization, especially in large clusters. We can delete the unused pod node field. 🤔
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
cc @ingvagabund
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.
should this move here instead?
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.
should this move here instead?
ditto
|
New changes are detected. LGTM label has been removed. |
Signed-off-by: Colvin-Y <[email protected]>
3509437 to
fb4bbfb
Compare
Signed-off-by: Colvin-Y <[email protected]>
|
Nice change @Colvin-Y - do you have any before/after results on memory footprint you can share? @ingvagabund How does a global change like this impact a plugin? For example, if I write my custom Descheduler plugin which relies on some of the omitted fields, can I override this behavior? |
hi @a7i Before cache start, you can override it. But maybe best practice is to modify func |
|
Each plugin might tell which fields are necessary. I.e. through a new method in the similar fashion as scheduler's This might be tricky to implement as each plugin will need different fields. So a simple clearing functions as in this PR will not suffice. |
|
/retest-required |
1 similar comment
|
/retest-required |
|
A naive solution would be to enumerate all fields. E.g.: c.Command = nil
c.Args = nil
c.WorkingDir = ""
c.Ports = nil
...into const (
POD_COMMAND = iota
POD_ARGS
POD_WORKING_DIR
POD_PORTS
...The same for nodes. Then, have each plugin to define a list of fields to preserve: func func (pl *Plugin) PreservedField() [] uint {
return []uint {POD_COMMAND, POD_ARGS, ...}
}Then iterate through all plugins, make a union of all if _, in := preservedFieldsMap[POD_COMMAND]; !in {
c.Command = nil
}
if _, in := preservedFieldsMap[POD_ARGS]; !in {
c.Args = nil
}
... |
ditto |
fix #1737
In production scenarios, the fields of pods are usually quite complex. Testing has shown that in our case, the descheduler's memory usage has been reduced by 2/5.