1

I tried using "perf" command in my Ubuntu Virtual Machine hosted on GCP. But when I run:

sudo perf stat -e task-clock,cycles,instructions,cache-references,cache-misses  ./AppName

Output:

    Performance counter stats for './AppName':
        490.299513      task-clock (msec)         #    0.081 CPUs utilized          
   <not supported>      cycles                                                      
   <not supported>      instructions                                                
   <not supported>      cache-references                                            
   <not supported>      cache-misses                                                
       6.036963754 seconds time elapsed

Except the task-clock all others are shown as "not supported". I want the cache-references and cache-misses data. So is there any alternative to "perf"?

krrish_007
  • 21
  • 1
  • 6

1 Answers1

2

I reproduced the same scenario in my project for ubuntu, redhat by using a different kind of machines (N1, N2) and having the same output as you provided:

root@perf-test-ubuntu:~# perf stat -e task-clock,cycles,instructions,cache-references,cache-misses ^C Performance counter stats for 'system wide':

  44450.342564      task-clock (msec)         #    1.000 CPUs utilized          
<not supported>      cycles                                                      
<not supported>      instructions                                                
<not supported>      cache-references                                            
<not supported>      cache-misses                                                

  44.470234233 seconds time elapsed

I found some useful links [1][2], it seems Linux perf tool by default tries to use hardware performance monitoring counters. When your OS is virtualized, you have no direct access to all counters; several virtualization solutions may allow access to some basic counters, if configured. [1]

The data you want is in hardware based Performance Monitoring Counters. These are typically NOT emulated by virtual machine environments because they are overhead and generally meaningless given the underlying caching statistics are maintained on a per core / package basis and the workload can be scheduled to run on a variety of cores, each with its own hardware level statistics. [2]

Hope these information are helpful for you.

[1]-Linux perf events profiling in Google Compute Engine not working

[2]-https://www.researchgate.net/post/Why_doesnt_perf_report_cache-refernces_cache-misses

Shafiq I
  • 406
  • 2
  • 7