Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Fix workingset memory calculation. #766

Merged
merged 1 commit into from May 11, 2018

Conversation

Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented May 11, 2018

Fix container workingset memory calculation.

In kubernetes and cadvisor, workingset is defined as "usage - total_inactive_file".
See https://github.com/google/cadvisor/blob/08f0c2397cbca790a4db0f1212cb592cc88f6e26/container/libcontainer/handler.go#L520.

/cc @dashpole @abhi

Signed-off-by: Lantao Liu lantaol@google.com

@Random-Liu Random-Liu added this to the v1.0.1 milestone May 11, 2018
@k8s-ci-robot
Copy link

@Random-Liu: GitHub didn't allow me to request PR reviews from the following users: dashpole.

Note that only containerd members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

Fix container workingset memory calculation.

In kubernetes and cadvisor, workingset is defined as "usage - total_inactive_file".
See https://github.com/google/cadvisor/blob/08f0c2397cbca790a4db0f1212cb592cc88f6e26/container/libcontainer/handler.go#L520.

/cc @dashpole

Signed-off-by: Lantao Liu lantaol@google.com

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/test-infra repository.

@@ -107,10 +107,12 @@ func (c *criService) getContainerMetrics(
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: metrics.CPU.Usage.Total},
}
}
if metrics.Memory != nil && metrics.Memory.Usage != nil {
if metrics.Memory != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we dont check metrics.Memory.Usage != nil anymore, missing memory metrics result in a adding a value with WorkingSet = 0, instead of cs.Memory = nil. I don't know the codebase, so I don't know if this matters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, good catch. I'll keep the behavior unchanged.

Copy link
Member

@abhi abhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

if memory.Usage == nil {
return 0
}
workingSet := memory.Usage.Usage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be set to zero here

return 0
}
workingSet := memory.Usage.Usage
if memory.TotalInactiveFile < workingSet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should compare with memory.Usage.Usage here

workingSet := memory.Usage.Usage
if memory.TotalInactiveFile < workingSet {
workingSet -= memory.TotalInactiveFile
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then remove else case

}
workingSet := memory.Usage.Usage
if memory.TotalInactiveFile < workingSet {
workingSet -= memory.TotalInactiveFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workingSet = memory.Usage.Usage - memory.TotalInactiveFile..

Signed-off-by: Lantao Liu <lantaol@google.com>
@Random-Liu
Copy link
Member Author

Random-Liu commented May 11, 2018

@mikebrow Done. Cleaner.

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@Random-Liu Random-Liu merged commit 66388ae into containerd:master May 11, 2018
@Random-Liu Random-Liu deleted the fix-workingset-memory branch May 11, 2018 22:48
Random-Liu added a commit that referenced this pull request May 12, 2018
Cherrypick #766 into release/1.0 branch.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants