可以“记录"或“性能记录"样本子进程? [英] can "perf record" or "perf-record" sample child processes?
问题描述
假设我有一个线束二进制文件,可以根据命令行选项生成不同的基准.我对抽样这些基准非常感兴趣.
我有3种选择:
-
更改工具二进制文件以生成性能记录"子进程,该子进程运行基准并进行采样
-
只需执行"perf record $ harness-binary",希望它也会对子进程进行采样.
-
性能记录-a $ harness-binary",它将执行从所有CPU进行系统范围的收集".这需要root访问,因此在我的情况下不可行.
如果性能记录确实对子进程进行采样,则方法2是干净的.有人可以帮助确认是否是这种情况吗?高度赞赏指向文档或性能代码的指针.
如果方法2是可行的,并且基准测试比测试工具要消耗更多的CPU资源,我认为基准采样的质量应该相当不错,对吧?
谢谢
perf记录
(不带 -a
选项)记录所有从目标进程分叉(和克隆的线程)的进程开始记录后.使用 perf record ./program
,它也会配置所有子进程,而使用 perf record -p $ PID
,并附加到已经运行的$ PID上,它将配置目标进程和所有附加后启动子进程.默认情况下,分析继承处于启用状态(所需代码如下: attr-> inherit =!opts-> no_inherit;
& https://perf.wiki.kernel.org/index.php/Tutorial
计数和继承
默认情况下,该进程的所有线程以及后续子进程和线程的perf stat计数.可以使用-i选项更改.无法获得每个线程或每个进程的计数细分.
还有 just do "perf record $harness-binary" hoping it will sample the child process too. "perf record -a $harness-binary" which would do a "System-wide collection from all CPUs.". This requires root access, therefore not feasible in my case. Approach #2 is clean if perf-record really samples the child process. Can somebody help to confirm if this is the case? Pointers to documents or perf code would be highly appreciated. If approach #2 is feasible and the benchmarks is much more CPU-intensive than the harness, I think the quality of the benchmark sampling should be reasonably good, right? Thanks This inheritance is like in Counting and inheritance By default, perf stat counts for all threads of the process and subsequent child processes and threads. This can be altered using the -i option. It is not possible to obtain a count breakdown per-thread or per-process. And -i
选项也用于 perf记录
:
perf record
without -a
option record all processes, forked (and threads cloned) from target process after starting of record. With perf record ./program
it will profile all child processes too, and with perf record -p $PID
with attaching to already running $PID it will profile target process and all child processes started after attaching. Profiling inheritance is enabled by default (code as required: attr->inherit = !opts->no_inherit;
& no_inherit) and can be disabled with -i
option and also disabled by -t
and --per-thread
.perf stat
: https://perf.wiki.kernel.org/index.php/Tutorial
-i
option is there for perf record
too: http://man7.org/linux/man-pages/man1/perf-record.1.html
-i, --no-inherit
Child tasks do not inherit counters.
perf report
can filter events from some PID from collected combined perf.data file.
这篇关于可以“记录"或“性能记录"样本子进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!