On Freitag, 9. Oktober 2015 14:24:17 CEST Brendan Gregg wrote:
> G'Day,
> 
> Maybe someone would like to code this (if not I hope to find the
> time); perf report already has the capability to print captured stacks
> as a call tree. I'd like a new output mode: folded.
> 
> Flame graphs[1] consume folded stacks. Eg:
> 
> # git clone https://github.com/brendangregg/FlameGraph
> # cd FlameGraph
> # perf record -F 99 -a -g -- sleep 60
> # perf script | ./stackcollapse-perf.pl | ./flamegraph.pl
> out.perf-folded > flame.svg
> 
> The last line is inefficient, and should really be something like:
> 
> # perf report --folded | ./flamegraph.pl out.perf-folded > flame.svg
> 
> The folded format is function names separated by semicolons, a space,
> then the count of occurrences. Eg:

<snip>

Hey Brendan,

did you consider writing a python script to do the folding? It's pretty simple 
nowadays, once you cross the initial bar.

I wrote this for stack collapsing futex locks:
https://paste.kde.org/p61qxah7d

And this to convert samples to callgrind format to open it in KCacheGrind:
https://paste.kde.org/pjfwd1e8f

If you combine the stack collapsing in the former with the generic 
process_event hook used in the latter, you should be all set. In my tests, it 
was pretty quick to convert stuff, certainly better than creating strings, 
pushing them to the console, and then parsing that again in perl.

perf script fold | flamegraph.pl > flame.svg

gets pretty close. If you want to test locally, make sure you use `perf script 
-s fold.py` or similar.

Cheers, and HTH

-- 
Milian Wolff | milian.wo...@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to