"perf record" 或 "perf-record" 可以采样子进程吗?
can "perf record" or "perf-record" sample child processes?
假设我有一个线束二进制文件,它可以根据命令行选项产生不同的基准测试。我真的很想对这些基准进行抽样。
我有 3 个选择:
更改 harness 二进制文件以生成一个 "perf record" 子进程,其中 运行 进行基准测试并进行采样
只是 "perf record $harness-binary" 希望它也能对子进程进行采样。
"perf record -a $harness-binary" 会做 "System-wide collection from all CPUs."。这需要 root 访问权限,因此在我的情况下不可行。
如果 perf-record 确实对子进程进行采样,则方法 #2 是干净的。有人可以帮助确认是否是这种情况吗?非常感谢指向文档或性能代码的指针。
如果方法 #2 可行并且基准比线束 CPU 密集得多,我认为基准抽样的质量应该相当不错,对吗?
谢谢
perf record
不带 -a
选项记录所有进程,记录开始后从目标进程分叉(和线程克隆)。使用 perf record ./program
它将分析所有子进程,并且使用 perf record -p $PID
附加到已经 运行 $PID 它将分析目标进程和附加后启动的所有子进程。默认情况下启用分析继承(所需代码:attr->inherit = !opts->no_inherit;
& no_inherit),可以使用 -i
选项禁用,也可以通过 -t
和 --per-thread
.
禁用
这种继承就像在perf stat
中一样:https://perf.wiki.kernel.org/index.php/Tutorial
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.
-i
选项也适用于 perf record
:http://man7.org/linux/man-pages/man1/perf-record.1.html
-i, --no-inherit
Child tasks do not inherit counters.
perf report
可以从收集的组合 perf.data 文件中过滤来自某些 PID 的事件。
假设我有一个线束二进制文件,它可以根据命令行选项产生不同的基准测试。我真的很想对这些基准进行抽样。
我有 3 个选择:
更改 harness 二进制文件以生成一个 "perf record" 子进程,其中 运行 进行基准测试并进行采样
只是 "perf record $harness-binary" 希望它也能对子进程进行采样。
"perf record -a $harness-binary" 会做 "System-wide collection from all CPUs."。这需要 root 访问权限,因此在我的情况下不可行。
如果 perf-record 确实对子进程进行采样,则方法 #2 是干净的。有人可以帮助确认是否是这种情况吗?非常感谢指向文档或性能代码的指针。
如果方法 #2 可行并且基准比线束 CPU 密集得多,我认为基准抽样的质量应该相当不错,对吗?
谢谢
perf record
不带 -a
选项记录所有进程,记录开始后从目标进程分叉(和线程克隆)。使用 perf record ./program
它将分析所有子进程,并且使用 perf record -p $PID
附加到已经 运行 $PID 它将分析目标进程和附加后启动的所有子进程。默认情况下启用分析继承(所需代码:attr->inherit = !opts->no_inherit;
& no_inherit),可以使用 -i
选项禁用,也可以通过 -t
和 --per-thread
.
这种继承就像在perf stat
中一样:https://perf.wiki.kernel.org/index.php/Tutorial
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.
-i
选项也适用于 perf record
:http://man7.org/linux/man-pages/man1/perf-record.1.html
-i, --no-inherit Child tasks do not inherit counters.
perf report
可以从收集的组合 perf.data 文件中过滤来自某些 PID 的事件。