【发布时间】:2020-04-27 10:14:56
【问题描述】:
我正在使用来自https://hub.docker.com/r/polinux/stress-ng/dockerfile 的stress-ng docker 映像来给我的系统施加压力。我想使用 perf 工具来监控指标。
perf stat -- stress-ng --cpu 2 --timeout 10 运行压力 ng 10 秒并返回性能指标。我尝试使用 perf stat -- docker run -ti --rm polinux/stress-ng --cpu 2 --timeout 10 对 docker 映像执行相同的操作。这会返回指标,但不会返回压力-ng 的指标。
在stress-ng上使用“perf stat”时得到的输出:
Performance counter stats for 'stress-ng --cpu 2 --timeout 10':
19975.863889 task-clock (msec) # 1.992 CPUs utilized
2,057 context-switches # 0.103 K/sec
7 cpu-migrations # 0.000 K/sec
8,783 page-faults # 0.440 K/sec
52,568,560,651 cycles # 2.632 GHz
89,424,109,426 instructions # 1.70 insn per cycle
17,496,929,762 branches # 875.904 M/sec
97,910,697 branch-misses # 0.56% of all branches
10.025825765 seconds time elapsed
在 docker 镜像上使用 perf 工具时得到的输出:
Performance counter stats for 'docker run -ti --rm polinux/stress-ng --cpu 2 --timeout 10':
154.613610 task-clock (msec) # 0.014 CPUs utilized
858 context-switches # 0.006 M/sec
113 cpu-migrations # 0.731 K/sec
4,989 page-faults # 0.032 M/sec
252,242,504 cycles # 1.631 GHz
375,927,959 instructions # 1.49 insn per cycle
84,847,109 branches # 548.769 M/sec
1,127,634 branch-misses # 1.33% of all branches
10.704752134 seconds time elapsed
有人可以帮助我了解如何在使用 docker 运行时获取压力-ng 的指标吗?
【问题讨论】:
-
您可以尝试将系统范围的性能统计信息与
perf stat -a一起使用。添加 per-cpu 分离将为您提供额外的信息:perf stat -a -A(或-a -C 2以选择要配置的 cpu 核心 2)。这并不准确,但易于使用。您的perf stat docker run可能不起作用,因为子进程不是从 docker 而是从 dockerd 守护进程启动的(默认情况下 perf stat 只依赖进程树)。您可以尝试在您的 docker 镜像中添加 perf 工具并使用类似docker run perf stat polinux/stress-ng的东西。