【发布时间】:2021-11-22 12:19:19
【问题描述】:
我正在为特定应用程序运行 C++ 基准测试。在这个测试中,我在临界区之前打开性能计数器文件(__NR_perf_event_open syscall),继续该部分,然后在读取指定的指标(指令、周期、分支、缓存未命中等)之后。
我验证这需要在 sudo 下运行,因为该进程需要 CAP_PERFCOUNT 功能。我还必须验证 /proc/sys/kernel/perf_event_paranoid 是否设置为大于 2 的数字,对于带有内核 5.11.0 的 Ubuntu 20.04.3 似乎总是如此,这是我在测试中标准化的操作系统。
此设置适用于我的所有本地计算机。但是,在云上,它仅适用于 m5zn.6xlarge(英特尔至强铂金 8252C)的某些实例。它不适用于其他 t3.medium、c3.4xlarge、c5a.8xlarge。
它们的 AMI 都是相同的 ami-09e67e426f25ce0d7。
验证此行为的一种简单方法是运行以下命令:
sudo perf stat /bin/sleep 1
在 m5zn 盒子上我会看到:
Performance counter stats for '/bin/sleep 1':
0.54 msec task-clock # 0.001 CPUs utiliz
1 context-switches # 0.002 M/sec
1 cpu-migrations # 0.002 M/sec
75 page-faults # 0.139 M/sec
2191485 cycles # 4.070 GHz
1292564 instructions # 0.59 insn per cyc
258373 branches # 479.860 M/sec
11090 branch-misses # 4.29% of all branc
1.000902741 seconds time elapsed
0.000889000 seconds user
0.000000000 seconds sys
在其他盒子上我会看到:
Performance counter stats for '/bin/sleep 1':
0.62 msec task-clock # 0.001 CPUs utilized
2 context-switches # 0.003 M/sec
0 cpu-migrations # 0.000 K/sec
76 page-faults # 0.124 M/sec
<not supported> cycles
<not supported> instructions
<not supported> branches
<not supported> branch-misses
1.002488031 seconds time elapsed
0.000930000 seconds user
0.000000000 seconds sys
Perf with not supported values
我怀疑 m5zn.6xlarge 由真实实例支持,而其他实例是共享实例。我的怀疑正确吗?
我可以启动哪些实例来为我提供性能计数器 PMU 支持?
谢谢!
【问题讨论】:
标签: amazon-web-services amazon-ec2 linux-kernel performancecounter intel-pmu