【发布时间】:2013-01-18 10:16:09
【问题描述】:
根据perf tutorials,perf stat 应该使用硬件计数器报告缓存未命中。但是,在我的系统(最新的 Arch Linux)上,它没有:
[joel@panda goog]$ perf stat ./hash
Performance counter stats for './hash':
869.447863 task-clock # 0.997 CPUs utilized
92 context-switches # 0.106 K/sec
4 cpu-migrations # 0.005 K/sec
1,041 page-faults # 0.001 M/sec
2,628,646,296 cycles # 3.023 GHz
819,269,992 stalled-cycles-frontend # 31.17% frontend cycles idle
132,355,435 stalled-cycles-backend # 5.04% backend cycles idle
4,515,152,198 instructions # 1.72 insns per cycle
# 0.18 stalled cycles per insn
1,060,739,808 branches # 1220.015 M/sec
2,653,157 branch-misses # 0.25% of all branches
0.871766141 seconds time elapsed
我错过了什么?我已经搜索了手册页和网络,但没有发现任何明显的内容。
编辑:我的 CPU 是 Intel i5 2300K,如果这很重要的话。
【问题讨论】:
-
这取决于您的硬件计数器。我从未使用过
perf,但我使用过PAPI(icl.cs.utk.edu/PAPI),并且可以检查可用的硬件计数器以了解您可以从 CPU 中获得什么。 -
试试
perf stat -d- 它会报告一些缓存事件。还要检查用于记录/报告内存事件的新perf mem工具 - 记录在 linuxtag.org/2013/fileadmin/www.linuxtag.org/slides/… 幻灯片 10 和 man7.org/linux/man-pages/man1/perf-mem.1.html -
osgx,
perf stat -d将打开事件多路复用,有时可能会报告错误的速率。每次运行最好手动选择不超过 5-7 个硬件事件;并仅使用 perf stat -d 来获取此类事件的名称。英特尔的其他方式 - 尝试来自 github.com/andikleen/pmu-tools 的 toplev.py
标签: linux caching optimization profiling perf