- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
Brendan D. Gregg(DTrace 书的作者)有一个有趣的分析变体:"Off-CPU" profiling (和 Off-CPU Flame Graph ; slides 2013, p112-137 )查看线程或应用程序在哪里被阻塞(不是由 CPU 执行,而是等待 I/O、页面错误处理程序或由于 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 上执行得更频繁)。
perf
分析工具?PS:在 slides from LISA13, p124 中有指向 Off-CPU 火焰图的 systemtap 变体的链接。 :“Yichun Zhang 创建了这些,并一直在 Linux 上使用它们和 SystemTap 来收集配置文件数据。参见: • http://agentzh.org/misc/slides/off-cpu-flame-graphs.pdf “”(CloudFlare 啤酒 session ,2013 年 8 月 23 日)
最佳答案
我发布的 perf 技术 [1] 是一个高开销的解决方法,直到 perf 有 BPF 支持这样做。
目前,在 Linux 上生成 off-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
关于linux - 如何使用linux `perf`工具生成 "Off-CPU"配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23098153/
我是一名优秀的程序员,十分优秀!