如何使用linux`perf`工具生成“Off-CPU”配置文件

前端之家收集整理的这篇文章主要介绍了如何使用linux`perf`工具生成“Off-CPU”配置文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Brendan D. Gregg(DTrace书的作者)有趣的变种: “Off-CPU” profiling(和 Off-CPU Flame Graph; slides 2013,p112-137)看到,线程或应用程序被阻止(没有被cpu执行,但是等待I / O,pagefault处理程序,或由于cpu资源不足而被排除):

This time reveals which code-paths are blocked and waiting while off-cpu,and for how long exactly. This differs from traditional profiling which often samples the activity of threads at a given interval,and (usually) only examine threads if they are executing work on-cpu.

他还可以将Off-cpu配置文件数据和On-cpu配置文件组合在一起:http://www.brendangregg.com/FlameGraphs/hotcoldflamegraphs.html

Gregg给出的示例使用dtrace,这在Linux操作系统中通常不可用.但是,有一些类似的工具(ktap,systemtap,perf)和perf,因为我认为最广泛的安装基础.通常perf生成的On-cpu配置文件(哪些功能cpu上执行得更频繁).

>如何将Gregg的Off-cpu示例转换为Linux中的perf性能分析工具?

PS:slides from LISA13,p124中有与Off-cpu火焰记录器的systemtap变体的链接:“Yichun Zhang创建了这些,并在Linux上使用SystemTap收集数据,参见:http://agentzh.org/misc/slides/off-cpu-flame-graphs.pdf”“(CloudFlare Beer Meeting on 23 2013年8月)

@H_502_15@解决方法
我发表的perf技术[1]是一个高开销的解决方法,直到perf有BPF支持这样做.

现在,在Linux上生成cpu火焰图的最低成本方法是在4.6内核(其具有BPF堆栈跟踪支持)以及bcc / BPF.我为它编写了一个工具,offcputime [2],可以使用-f选项来运行“折叠输出”,适用于进入flamegraph.pl.这个offcputime工具在内核内容中执行计时和堆栈计数,并转储一个随后用符号打印的报告.

有一天,我期望perf本身也能够做到这一点:运行一个执行内核计数的BPF程序,并倾倒报告.

在此期间,我们可以使用bcc / BPF.如果由于某种原因,您不能使用bcc,您现在可以使用该offcputime程序并将其写入C.Linux源代码中提供了更复杂的版本,如samples / bpf / offwaketime *.在Linux上使用新的BPF功能,如果有意志,就有办法.

[1] http://www.brendangregg.com/blog/2015-02-26/linux-perf-off-cpu-flame-graph.html

[2] https://github.com/iovisor/bcc/blob/master/tools/offcputime_example.txt

原文链接:https://www.f2er.com/linux/393736.html

猜你在找的Linux相关文章