"perf"可以在 Google Cloud Platform 上运行的替代性能管理工具



我尝试在GCP上托管的Ubuntu虚拟机中使用"perf"命令。但当我跑步时:

sudo perf stat -e task-clock,cycles,instructions,cache-references,cache-misses  ./AppName

输出:

Performance counter stats for './AppName':
490.299513      task-clock (msec)         #    0.081 CPUs utilized          
<not supported>      cycles                                                      
<not supported>      instructions                                                
<not supported>      cache-references                                            
<not supported>      cache-misses                                                
6.036963754 seconds time elapsed

除任务时钟外,其他所有时钟均显示为"不支持"。我想要缓存引用和缓存未命中数据。那么,除了"perf"还有其他选择吗?

我在我的ubuntu项目中为redhat复制了相同的场景,使用了不同类型的机器(N1,N2(,并具有与您提供的相同的输出:

root@perf-test-ubuntu:~#perf-stat-e任务时钟、周期、指令、缓存引用、缓存未命中^C"全系统"的性能计数器统计信息:

44450.342564      task-clock (msec)         #    1.000 CPUs utilized          
<not supported>      cycles                                                      
<not supported>      instructions                                                
<not supported>      cache-references                                            
<not supported>      cache-misses                                                
44.470234233 seconds time elapsed

我发现了一些有用的链接[1][2],Linux perf工具似乎默认情况下会尝试使用硬件性能监视计数器。当您的操作系统被虚拟化时,您无法直接访问所有计数器;几个虚拟化解决方案可能允许访问一些基本计数器(如果配置的话(。[1]

所需的数据位于基于硬件的性能监视计数器中。这些通常不会被虚拟机环境模拟,因为它们是开销,并且通常没有意义,因为底层缓存统计信息是在每个核心/包的基础上维护的,并且工作负载可以安排在各种核心上运行,每个核心都有自己的硬件级统计信息。[2]

希望这些信息对你有帮助。

[1] -谷歌计算引擎中的Linux perf事件分析不起作用

[2]-https://www.researchgate.net/post/Why_doesnt_perf_report_cache-refernces_cache-misses

最新更新