简体   繁体   中英

Linux Perf Counting Instructions, Cycles, Cache misses more lightweight over a long time

I want to profile some programs under different restrictions for my research. I use perf tool to measure some counters. This profiling will go for a long time (hours), and perf tool generates too much data that I don't need. For instance:

$ 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) ]

It is approrixmately 1.92 MBs per second. In 24 hours, it will be 165 GBs. When I used the perf report tool, I saw that it also kept function calls which I do not need. How can I make the perf-record work more lightweight and record only the data I need? I only need the analyze the following data over time to see how they change with some changes I make to system. Considering it records a lot of data, and I will use it in 24 core machines makes the data very large. Best option so far is to record periodically and analyze the perf.data to get the integers I want and delete it, but I believe there should be a better option since I can miss some profiling data in that window.

 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     

Does simple perf stat output good for you? For example

$ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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