Search code examples
linuxperf

what's the meaning of cycles annotation in perf stat


      8.014196 task-clock                #    0.004 CPUs utilized          
           204 context-switches          #    0.025 M/sec                  
            32 cpu-migrations            #    0.004 M/sec                  
             0 page-faults               #    0.000 K/sec                  
    11,841,196 cycles                    #    1.478 GHz                     [46.17%]
     9,982,788 stalled-cycles-frontend   #   84.31% frontend cycles idle    [80.26%]
     8,122,708 stalled-cycles-backend    #   68.60% backend  cycles idle   
     5,462,302 instructions              #    0.46  insns per cycle        
                                         #    1.83  stalled cycles per insn
     1,098,309 branches                  #  137.045 M/sec                  
        94,430 branch-misses             #    8.60% of all branches         [77.23%]

what's the meaning of 1.478 GHz and [46.17%] in cycles's annotation.


Solution

  • This is a thing I hate very much on perf, that the documentation and manual pages are outdated and searching for meaning of some values is pretty complicated. I did search for them once so I add my findings:

    what's the meaning of 1.478 GHz

    To my knowledge, the value after # is recalculation of the native counter value (the value in the first column) to the user-readable form. This value should roughly correspond to clock speed of your processor:

    grep MHz /proc/cpuinfo
    

    should give similar value. It is printed from tools/perf/util/stat-shadow.c.

    and [46.17%] in cycles's annotation?

    This value should correspond the the portion of time, the hardware counter was active. Perf allows to start more hardware counters and multiplex them in runtime, which makes it easier for programmer.

    I didn't found the actual place in the code, but it is described in one recently proposed patch as (part of csv format):

    +   - percentage of measurement time the counter was running