Linux Perf计数指令,周期,缓存在很长一段时间内错过了更轻量级

时间:2016-01-24 21:52:24

标签: linux performance profiling perf

我想介绍一些针对我的研究的不同限制的程序。我使用perf工具来测量一些计数器。此分析将持续很长时间(小时),并且perf工具会生成太多我不需要的数据。例如:

$ perf record -e cycles,instructions,cache-misses,cpu-clock,context-switches,cpu-migrations ./stress-ng --cpu 4 --cpu-ops 10000
stress-ng: info:  [6642] defaulting to a 86400 second run per stressor
stress-ng: info:  [6642] dispatching hogs: 4 cpu
stress-ng: info:  [6642] successful run completed in 15.57s
[ perf record: Woken up 117 times to write data ]
[ perf record: Captured and wrote 29.971 MB perf.data (~1309444 samples) ]

每秒1.92 MB是非常合适的。在24小时内,它将是165 GB。当我使用perf报告工具时,我看到它还保留了我不需要的函数调用。如何使perf-record工作更轻量级并仅记录我需要的数据?我只需要随着时间的推移分析以下数据,看看它们如何随着我对系统所做的一些改变而改变。考虑到它记录了大量数据,我将在24台核心机器中使用它使数据非常大。到目前为止,最好的选择是定期记录并分析perf.data以获取我想要的整数并删除它,但我相信应该有更好的选择,因为我可以错过该窗口中的一些分析数据。

 Performance counter stats for './stress-ng --cpu 4 --cpu-ops 10000':

   128.290.294.651      cycles                   
   201.217.788.817      instructions              #    1,57  insns per cycle        
         3.048.096      cache-misses                                                
      40340,258757      cpu-clock (msec)                                            
               123      context-switches                                            
                25      cpu-migrations                                              

      10,205760993 seconds time elapsed     

1 个答案:

答案 0 :(得分:2)

简单的perf stat输出对你有用吗?例如

$ perf stat -e cycles,instructions,cache-misses,cpu-clock,context-switches,cpu-migrations date 
Sun Jan 24 18:46:10 EST 2016

 Performance counter stats for 'date':

         1,269,265      cycles                   
           660,875      instructions              #    0.52  insns per cycle        
             2,265      cache-misses                                                
          0.644391      cpu-clock (msec)                                            
                 2      context-switches                                            
                 1      cpu-migrations                                              

       0.001031207 seconds time elapsed
相关问题