pkg/discovery: systemd discoverer with less allocs#1426
pkg/discovery: systemd discoverer with less allocs#1426javierhonduco merged 2 commits intoparca-dev:mainfrom
Conversation
a3f9b52 to
9c256cd
Compare
|
I've finished working on the systemd package and updated the PR, please review. |
The current version makes use of 1163552 B/op, 32332 allocs/op to get a list of systemd services along with their PIDs. That accounts for 40% of CPU cycles, excluding the GC time. The proposed change gets 14304 B/op, 30 allocs/op.
9c256cd to
ed1f20c
Compare
kakkoyun
left a comment
There was a problem hiding this comment.
LGTM ❤️ 💚 💙 💛 💜
I need more time to read the code in https://github.com/marselester/systemd
However, it seems like we have the parity and the benchmark numbers look great 🚀
|
Looks amazing! Thanks so much for the very thorough work here.
I assume this comment is not up to date, right? :D Happy to land this change and test it in our machines and in our Demo environment 😄 |
|
Since the scope is dramatically reduced, would it make sense to move the systemd package into the parca-agent repo? Happy to discuss that as a follow up though ... |
@javierhonduco that's right :) |
|
@brancz sure, that can be done. It would be good to keep README.md and bench-old.txt within a package to retain a context. Another option is to fork the repository. |
|
Let's merge this to include it in the release we are cutting today and we can fork/move the code later on |
Hi! I would like to share some of the results I got with https://github.com/marselester/systemd.
There are still things I need to finish though...The current version of
discovery.SystemdDiscoverermakes use of 1.1 MB/op and 32,332 allocs/op to get a list of systemd services along with their PIDs. That accounts for 40% of CPU cycles in the agent, excluding the GC time, see https://pprof.me/e711789. The proposed change gets 13.96 KB/op and 30 allocs/op.I ran the benchmarks as follows:
pkg/discovery/kubernetes.goor else tests won't rungithub.zerozr99.workers.dev/parca-dev/parca-agent/pkg/cgroup: build constraints exclude all Go files in /vagrant/parca-agent/pkg/cgrouppkg/discovery/systemd_test.gosudo go test -run=^$ -bench=. -benchmem .Details
I've added
fmt.Printfto see whether the current implementation and a new one show the same services/PIDs.I also tried to stop and start a cron service to make sure that was picked up in the updates.
The output matches.
It would be cool if you guys could have a look and give it a go in a safe environment.