Filtering perf stacks based on number of samples

85 views Asked by At

After a perf record run, I can create a text file containing folded stacks via

perf script | ~/FlameGraph/stackcollapse-perf.pl > unprocessed_stacks.txt

In these unprocessed_stacks.txt, I might have a recursively called [unknown] function which is only sampled once, for example:

[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown];[unknown]; 1

When I construct a flamegraph out of this, I have a very thin peak which dominates the vertical scale but otherwise provides no insight into the data.

I would like to either 1) discard all folded stacks which comprise less than (say) 0.1% of the total samples recorded in the perf.data, or 2) put all of these low frequency stacks into a [misc] N bin.

This is a straightforward script to write in say awk or python, but is this already supported in the Flamegraph toolsuite or is it supported natively by perf?

0

There are 0 answers