The background is that I want to collect lbr events on the machine for pgo. But when I execute perf, I find that the CPU utilization of the processes running on the machine will increase. I am confused about the reason behind it. I don’t know much about perf. Do you have any ideas for troubleshooting?
The operation I performed
perf record -a -c 25000000 -b -e cycles:up
I want to use -a to collect data of all processes on the machine. And I tested that even if I use -F 1
or -c 1000000000
(1e9), it still has an impact. If I remove -b, there will be no impact. Does perf occupy any special resources when sampling branch events?
Machine and perf version
- perf version 4.18.0-2.3.5 (but it should not be related to the perf version, I have tried different versions and all have the same problem)
- os: Linux 4.18.0-2.4.3.3.x86_64
- cpu: Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
Because perf
performs additional work to collect metrics.
While perf
offers low-overhead profiling compared to its competition, it still incurs some overhead. At the very least, it needs to collect and write its performance statistics to disk. It also allows you to instrument code, i.e. add instructions which get executed at various points during measurement.
https://perf.wiki.kernel.org/index.php/Useful_Links contains a lot more information, but as Wikipedia notes, the available documentation is somewhat scattered and unapproachable.