optimize: preserving needed fields for memory efficiency#1738
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. DetailsNeeds 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. DetailsInstructions 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 |
|
|
||
| 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.
Using SetTransform seems to be very helpful for memory optimization, especially in large clusters. We can delete the unused pod node field. 🤔
|
New changes are detected. LGTM label has been removed. |
Signed-off-by: Colvin-Y <125539393+Colvin-Y@users.noreply.github.com>
3509437 to
fb4bbfb
Compare
Signed-off-by: Colvin-Y <125539393+Colvin-Y@users.noreply.github.com>
|
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 |
| c.Command = nil | ||
| c.Args = nil | ||
| c.WorkingDir = "" | ||
| c.Ports = nil |
There was a problem hiding this comment.
I suggest not removing this c.Ports. The NodePorts plugin in the scheduler needs to use the container’s ports, and the related field values may be required during the node fit phase.
There was a problem hiding this comment.
ack, I need some time to refact all as
func func (pl *Plugin) PreservedField() [] uint {
return []uint {POD_COMMAND, POD_ARGS, ...}
}
|
PR needs rebase. DetailsInstructions 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. |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
@Colvin-Y: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. I understand the commands that are listed here. |
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.