linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brendan Gregg <brendan.d.gregg@gmail.com>
To: Milian Wolff <milian.wolff@kdab.com>
Cc: "linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: Re: perf report feature request: folded stack output
Date: Tue, 20 Oct 2015 17:51:46 -0700	[thread overview]
Message-ID: <CAE40pde2AtkVGM8ophK3y2Yu75Prbfr-YsroPC4pvZienk2R6w@mail.gmail.com> (raw)
In-Reply-To: <2844120.msKGatE6uD@agathebauer>

On Fri, Oct 9, 2015 at 4:33 PM, Milian Wolff <milian.wolff@kdab.com> 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

      reply	other threads:[~2015-10-21  0:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-09 21:24 perf report feature request: folded stack output Brendan Gregg
2015-10-09 22:13 ` Brendan Gregg
2015-10-09 23:33 ` Milian Wolff
2015-10-21  0:51   ` Brendan Gregg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE40pde2AtkVGM8ophK3y2Yu75Prbfr-YsroPC4pvZienk2R6w@mail.gmail.com \
    --to=brendan.d.gregg@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).