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

Scan whole /sys/fs/cgroup directory in the cgroup decoder and use a faster filepath.WalkDir function #106

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

zuzzas
Copy link
Contributor

@zuzzas zuzzas commented Sep 9, 2021

  1. Scan whole /sys/fs/cgroup directory in the cgroup decoder.
    This resolves a problem when you are using a Hybrid systemd cgroup mode.
    Reference: https://systemd.io/CGROUP_DELEGATION/
  2. Use a newer filepath.WalkDir function to traverse the cgroup hierarchy. It provides a major speedup to the refresh process.

This resolves a problem when you are using a Hybrid systemd cgroup mode

Reference: https://systemd.io/CGROUP_DELEGATION/
@zuzzas
Copy link
Contributor Author

zuzzas commented Sep 13, 2021

@bobrik

@bwplotka
Copy link
Contributor

bwplotka commented Sep 15, 2021

I think this will only work if users use cgroups v1. For v2 cgroups we need to look in unified no?

Ignore me unified is child of the dir we look on, in this PR (:

@bwplotka
Copy link
Contributor

Context: I have issues with latency of this endpoint - it takes a huge amount of time to traverse through that refresh when new cgroup id appears. We need faster mechanism here.

@bwplotka
Copy link
Contributor

Ideally with this: bpftrace/bpftrace#1500

@bwplotka
Copy link
Contributor

Added issue: #109

@zuzzas
Copy link
Contributor Author

zuzzas commented Sep 15, 2021

@bwplotka
Thanks for the comment. There is a faster implementation of Walk if you are not concerned with Stat()ing every single file. I see a major speedup on a Linux laptop with the newest commit.

root@b5dace1effc1:/src/decoder# go test -run=XXX -bench=. .
goos: linux
goarch: amd64
pkg: github.com/cloudflare/ebpf_exporter/decoder
cpu: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
BenchmarkCgroupRefresh-8              55          19956497 ns/op
PASS
ok      github.com/cloudflare/ebpf_exporter/decoder     1.142s

root@b5dace1effc1:/src/decoder# go test -run=XXX -bench=. .
goos: linux
goarch: amd64
pkg: github.com/cloudflare/ebpf_exporter/decoder
cpu: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
BenchmarkCgroupRefresh-8              24          47062521 ns/op
PASS
ok      github.com/cloudflare/ebpf_exporter/decoder     1.838s

@zuzzas zuzzas changed the title Scan whole /sys/fs/cgroup directory in the cgroup decoder Scan whole /sys/fs/cgroup directory in the cgroup decoder and use a faster filepath.WalkDir function Sep 15, 2021
@bobrik
Copy link
Contributor

bobrik commented Sep 15, 2021

LGTM. @bwplotka, are you happy with this?

@bobrik bobrik merged commit 98fd586 into cloudflare:master Sep 29, 2021
@zuzzas zuzzas deleted the cgroup-path-fix branch September 29, 2021 05:37
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.

3 participants