-
Notifications
You must be signed in to change notification settings - Fork 23
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
Improve memory usage of Istio manager #852
Changes from 4 commits
5567e43
760b13e
006cb1f
110efb2
4b2445f
792d60d
e4f4cbf
2ecdfb5
5b26c43
fd65944
565bb7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,32 +51,32 @@ func getAllRunningPods(ctx context.Context, c client.Client) (*v1.PodList, error | |
return podList, nil | ||
} | ||
|
||
func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList v1.PodList, err error) { | ||
func GetPodsToRestart(ctx context.Context, c client.Client, expectedImage SidecarImage, expectedResources v1.ResourceRequirements, predicates []filter.SidecarProxyPredicate, logger *logr.Logger) (outputPodsList *v1.PodList, err error) { | ||
podList, err := getAllRunningPods(ctx, c) | ||
if err != nil { | ||
return outputPodsList, err | ||
return nil, err | ||
} | ||
|
||
podList.DeepCopyInto(&outputPodsList) | ||
outputPodsList.Items = []v1.Pod{} | ||
|
||
//Add predicate for image version and resources configuration | ||
predicates = append(predicates, NewRestartProxyPredicate(expectedImage, expectedResources)) | ||
|
||
for _, predicate := range predicates { | ||
evaluator, err := predicate.NewProxyRestartEvaluator(ctx) | ||
if err != nil { | ||
return v1.PodList{}, err | ||
return &v1.PodList{}, err | ||
} | ||
|
||
outputPodsList = &v1.PodList{} | ||
for _, pod := range podList.Items { | ||
if evaluator.RequiresProxyRestart(pod) { | ||
outputPodsList.Items = append(outputPodsList.Items, *pod.DeepCopy()) | ||
outputPodsList.Items = append(outputPodsList.Items, pod) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a micro-optimization since the pod objects are not that big, but I think we will create multiple backing arrays, since the capacity of the slices will increase multiple times. That will lead to multiple arrays being kept in memory until the outputPodList isn't referenced any longer and can be garbage collected. |
||
} | ||
} | ||
} | ||
|
||
logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) | ||
if outputPodsList != nil { | ||
logger.Info("Pods to restart", "number of pods", len(outputPodsList.Items)) | ||
} | ||
return outputPodsList, nil | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 we add a comment that explains why we disable the cache for this types?