简体   繁体   English

性能:软件事件之间的奇怪关系

[英]perf: strange relation between software events

Okay, so this really bugs me. 好的,这真的让我很烦。

I'm using perf to record the cpu-clock event (a software event): 我正在使用perf记录cpu-clock事件(一个软件事件):

$ > perf record -e cpu-clock srun -n 1 ./stream

... and the table produced by perf report is empty. ...,并且perf报告生成的表为空。

I'm using perf to record all available software events listed in perf list: 我正在使用perf来记录perf列表中列出的所有可用软件事件:

$ > perf record -e alignment-faults,context-switches,cpu-clock,cpu-migrations,\
dummy,emulation-faults,major-faults,minor-faults,page-faults,task-clock\
srun -n 1 ./stream

... the table gives me a list of available samples: ...表格为我提供了可用样品的列表:

0 alignment-faults                                   
125 context-switches                                                
255 cpu-clock                                                  
21 cpu-migrations                                                        
0 dummy                                                              
0 emulation-faults                                             
0 major-faults                                                      
128 minor-faults                 
132 page-faults                                                           
254 task-clock 

I can look at the samples collected in cpu-clock and it gives me information. 我可以查看在cpu-clock中收集的样本,它为我提供了信息。 Why?! 为什么?! Why does it not work if I only measure cpu-clock? 如果仅测量cpu-clock,为什么它不起作用? Why were there no samples collected in four events? 为什么在四个事件中没有收集到样本?

This is a follow-up to this question: error: perf.data file has no samples 这是此问题的后续措施: 错误:perf.data文件没有样本

Probably srun don't start target process with direct fork. 也许srun不启动直接叉目标进程。 It may use some varian ot remote shell like ssh or daemon to start processes. 它可能会使用诸如ssh或daemon之类的各种远程shell启动进程。

perf record (without -a option) will track only directly forked sub-processes, not the process started (forked) by sshd or other daemon. perf record (不带-a选项)将仅跟踪直接分叉的子进程,而不跟踪由sshd或其他守护程序启动(分叉)的进程。 And it will never profile remote machine if the srun can go to it and perf record ... srun command was used (this is to profile srun application and everything it forks). 如果srun可以访问远程计算机并执行perf record ... srun ,那么它将永远不会对远程计算机进行概要分析perf record ... srun命令(这是对srun应用程序及其派生的一切进行概要分析)。

Try perf stat first to get total (raw) performance counters, and put perf as srun argument; 首先尝试perf stat以获得总(原始)性能计数器,然后将perf用作srun参数; this is the correct usage with tools which uses remote shell or daemons (probably with full path to perf): 这是使用远程外壳程序或守护程序的工具的正确用法(可能具有perf的完整路径):

 srun -n 1 perf stat ./stream
 srun -n 1 /usr/bin/perf stat ./stream

perf stat will print running time of target task. perf stat将打印目标任务的运行时间。 Then select some event with high raw counter (perf record usually tune sample rate to around several kHz, so thousands of samples will be generated, if there are enough raw event counts): 然后选择一些原始计数器较高的事件(性能记录通常将采样率调整到几kHz左右,如果有足够的原始事件计数,则将生成数千个样本):

 srun -n 1 perf record -e cpu-clock ./stream
 srun -n 1 /usr/bin/perf record -e cpu-clock ./stream

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM