Skip to content

Skip subcontainer update on v2 calls #1722

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

Merged
merged 2 commits into from
Aug 18, 2017

Conversation

sjenning
Copy link
Contributor

@sjenning sjenning commented Aug 17, 2017

Currently GetInfo() updates both the spec and the subcontainers. The subcontainer walk is VERY expensive as it does a stat syscall on basically every directory and file in the cgroupfs tree via ioutil.Readdir(). This uses lots of CPU directly and also allocates a TON of objects that have to be GCed later, consuming even more CPU.

AFAICT, the v2 api does not need to do this subcontainer update at all since the v2 ContainerInfo doesn't have a subcontainers field:
https://github.com/sjenning/cadvisor/blob/master/info/v1/container.go#L128-L139
https://github.com/sjenning/cadvisor/blob/master/info/v2/container.go#L59-L65

The code supports this conclusion as v2 go paths look like this

cinfo, err := container.GetInfo(false)
...
result.Spec = self.getV2Spec(cinfo)

The Subcontainers in the containerInfo is discarded.

This is a huge performance win. In Kubernetes, GetContainerInfoV2() is called every 10s from the summaryProvider. It is currently one of the top ~5 hot paths in steady-state kubelet.

@derekwaynecarr @smarterclayton @dashpole @vishh @tallclair

@smarterclayton
Copy link
Contributor

Nice dig

@sjenning sjenning force-pushed the skip-subcontainer-update-v2 branch from 223530f to 3ba4699 Compare August 17, 2017 17:36
@sjenning
Copy link
Contributor Author

cc @tallclair

@sjenning sjenning closed this Aug 17, 2017
@sjenning sjenning reopened this Aug 17, 2017
@sjenning
Copy link
Contributor Author

That "Close and comment" button should be red! 😖

@sjenning
Copy link
Contributor Author

@dashpole @tallclair if I can get a review on this in short order, I'll update my kube bump PR kubernetes/kubernetes#50629 to include this change.

@dashpole
Copy link
Collaborator

ill take a look today later today.

@derekwaynecarr
Copy link
Collaborator

LGTM, will let @dashpole review before merging.

Awesome investigation. Seeing the profile before and after is really helpful.

Copy link
Collaborator

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

LGTM, great stuff

@dashpole dashpole merged commit 27e1acb into google:master Aug 18, 2017
openshift-merge-robot added a commit to openshift/origin that referenced this pull request Aug 22, 2017
Automatic merge from submit-queue (batch tested with PRs 15861, 15865, 15873, 15848, 15891)

UPSTREAM: google/cadvisor: 1722: Skip subcontainer update on v2 calls

google/cadvisor#1722

This change results in a significant CPU reduction on the node.

@derekwaynecarr @eparis @smarterclayton
openshift-merge-robot added a commit to openshift/origin that referenced this pull request Aug 24, 2017
Automatic merge from submit-queue

UPSTREAM: google/cadvisor: 1722: Skip subcontainer update on v2 calls

3.6 pick of #15873

xref google/cadvisor#1722

@derekwaynecarr @eparis @smarterclayton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants