-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
Nice dig |
223530f
to
3ba4699
Compare
cc @tallclair |
That "Close and comment" button should be red! 😖 |
@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. |
ill take a look today later today. |
LGTM, will let @dashpole review before merging. Awesome investigation. Seeing the profile before and after is really helpful. |
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, great stuff
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
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
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 viaioutil.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
The
Subcontainers
in thecontainerInfo
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