0

I would like to know if it is possible to modify easily perf linux with stat module to create an interval of cycles (or instructions by cycle) instead of an interval of time ? The goal is to optimize the precision of the counters got by interval. The time unit is not accurate enough.

I have a friend which submits this idea but I looked the source code a little and I understood (maybe I have wrong) that we :

  • create a condition for a time calculated with the rdtsc library (some clock_gettime)
  • create a "wait" in the perf processus
  • launch the program to test
  • test if we respect the time condition : we continue or we break the wait function with a save on the mapped register system information in perf (and call the wait function if it is not over)

I would like this result :

 cycles     counts     unit events                                                    
 10000      25000      instructions   
 10000      450      branch-misses
 20000      21000      instructions   
 20000      850      branch-misses 

Unfortunately, I'm seeing a big problem if I want to use the result of a counter like a condition I have not yet. Or should I get all the time this or these counter(s) which define my "interval condition" ? I also saw that for a time interval, we shouldn't get counters with a frequency lower than 100ms because it generates overhead. If I get some counters every 10000 cycles, would I have the same problems ? I don't know where is this overhead (calls system ?).

  • Not really because my problematic is not the sampling. I want to count all events while a perf stat with the interval option. However, the time unit proposed is not accurate enough (minimum 10ms) and it's a problem for me. I look for something like 10000 cycles. But thank you. – Matthmatth03 Jan 31 '22 at 16:53
  • There are a couple earlier question about sampling all the counters when a specific one fires, which could potentially do what you want with the right overflow condition for the `cycles` event: [Using perf to get events counts depending on the occurrence of other events](https://stackoverflow.com/q/49912451) /[Variable event count based sampling using perf](https://stackoverflow.com/q/58903473). But at that time, it wasn't possible with the `perf` command line tool; maybe with PAPI system calls. – Peter Cordes Jan 31 '22 at 17:57

0 Answers0