Skip to content
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

container/libcontainer: Improve limits file parsing perf #3396

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

brancz
Copy link
Contributor

@brancz brancz commented Sep 15, 2023

Only max open files is ever parsed from limits files, therefore this
change optimizes for that case.

Benchmark:

$ benchstat old.txt new.txt
goos: linux
goarch: amd64
pkg: github.com/google/cadvisor/container/libcontainer
cpu: AMD Ryzen 5 3400GE with Radeon Vega Graphics
                    │   old.txt    │               new.txt               │
                    │    sec/op    │   sec/op     vs base                │
ProcessLimitsFile-8   85.012µ ± 1%   1.324µ ± 0%  -98.44% (p=0.000 n=10)

On a GKE v1.27.4 production cluster, this code path used roughly 1.5% of
the total kubelet CPU usage, and at 98.44% improvement this likely
results in at least a 1.5% CPU reduction (perhaps even more since also
less garbage is produced to be collected by the GC).

This change came out of a live stream that we do on a weekly basis trying to improve performance of popular open source software. Episode is here: https://www.youtube.com/watch?v=ricEoAdJNHc

Only max open files is ever parsed from limits files, therefore this
change optimizes for that case.

Benchmark:

```
$ benchstat old.txt new.txt
goos: linux
goarch: amd64
pkg: github.com/google/cadvisor/container/libcontainer
cpu: AMD Ryzen 5 3400GE with Radeon Vega Graphics
                    │   old.txt    │               new.txt               │
                    │    sec/op    │   sec/op     vs base                │
ProcessLimitsFile-8   85.012µ ± 1%   1.324µ ± 0%  -98.44% (p=0.000 n=10)
```

On a GKE v1.27.4 production cluster, this code path used roughly 1.5% of
the total kubelet CPU usage, and at 98.44% improvement this likely
results in at least a 1.5% CPU reduction (perhaps even more since also
less garbage is produced to be collected by the GC).
@k8s-ci-robot
Copy link
Collaborator

Hi @brancz. Thanks for your PR.

I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@dashpole
Copy link
Collaborator

/ok-to-test

@dashpole
Copy link
Collaborator

@bobbypage
Copy link
Collaborator

Thanks for the performance improvement, looks very reasonable to me, LGTM!

@brancz
Copy link
Contributor Author

brancz commented Sep 26, 2023

What do we need to do to get this merged? :)

Copy link
Collaborator

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

Looks fine with me. I doubt we will hit any instances where case sensitive check vs case insensitive check will matter

@bobbypage if you have concerns, please comment. Otherwise let's merge

@bobbypage
Copy link
Collaborator

/lgtm

@bobbypage bobbypage merged commit 28d5bdd into google:master Sep 26, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants