On Fri, Oct 9, 2015 at 4:33 PM, Milian Wolff <[email protected]> wrote: > 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.
Thanks, I did check them out (those links since expired), and that is an improvement! But I can't help but think that perf report already has the logic for creating a call tree, and it would be more efficient if perf could just dump in folded output directly -- without a python coprocess. Brendan -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
