Bo Liu
Bo Liu

Reputation: 31

Why does perf fail to collect any samples?

sudo perf top shows "Events: 0 cycles".

sudo perf record -ag sleep 10 shows

[ perf record: Woken up 1 time to write data ]
[ perf record: Captured and wrote 0.154 MB perf.data (~6725 samples) ]

However, sudo perf report shows "The perf.data file has no samples!". Also I checked the perf.data recorded and confirmed there is no any samples in it.

The system is "3.2.0-86-virtual #123-Ubuntu SMP Sun Jun 14 18:25:12 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux". perf version 3.2.69

Inputs are appreciated.

Upvotes: 3

Views: 4978

Answers (1)

osgx
osgx

Reputation: 94225

There may be no real samples on idle virtualized system (your linux kernel version has "-virtual" suffix); or there may be no access to hardware counters (-e cycles), which are used by default.

Try to profile some real application like

 echo '2^2345678%2'| sudo perf record /usr/bin/bc

Also check software counters like -e cpu-clock:

 echo '2^2345678%2'| sudo perf record -e cpu-clock /usr/bin/bc

You may try perf stat (perf stat -d) with same example to find which basic counters are really incremented in your system:

 echo '2^2345678%2'| sudo perf stat /usr/bin/bc

About "(~6725 samples)" output - perf record doesn't not count samples in its output, it just estimates their count but this estimation is always wrong. There is some fixed part of any perf.data file without any sample, it may use tens of kb in system-wide mode; and estimation incorrectly counts this part as containing some events of mean length.

Upvotes: 3

Related Questions