linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brendan Gregg <brendan.d.gregg@gmail.com>
To: "linux-perf-use." <linux-perf-users@vger.kernel.org>
Subject: perf report feature request: folded stack output
Date: Fri, 9 Oct 2015 14:24:17 -0700	[thread overview]
Message-ID: <CAE40pddHkm_SB4mpOBeSfTe8BcfU1js5fiEK96xA95gbjPa1bg@mail.gmail.com> (raw)

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:

iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sock_recvmsg;inet_recvmsg;tcp_recvmsg;tcp_release_cb
1
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sock_recvmsg;inet_recvmsg;tcp_recvmsg;tcp_v4_do_rcv
1
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sock_recvmsg;security_socket_recvmsg
2
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sock_recvmsg;tcp_recvmsg
2
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sockfd_lookup_light;__fdget;__fget_light;__fget
9
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;SYSC_recvfrom;sockfd_lookup_light;__fget_light
4
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;fput 2
iperf;__libc_recv;entry_SYSCALL_64_fastpath;sys_recvfrom;sockfd_lookup_light 1
iperf;__libc_recv;sys_recvfrom 3
iperf;__pthread_disable_asynccancel 11
iperf;check_events;xen_hypercall_xen_version 37

etc.

It should just be a different way of printing "perf report -n
--stdio", so I hope most of the logic is already there. :)

Folded output would be great. An optional additional output could be
JSON. I'm helping build an open source GUI that consumes profiles, and
it's consuming similar aggregated stacks but as JSON. Eg:
https://github.com/spiermar/d3-flame-graph/blob/master/example/stacks.json

Brendan

[1] http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html

             reply	other threads:[~2015-10-09 21:24 UTC|newest]

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

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=CAE40pddHkm_SB4mpOBeSfTe8BcfU1js5fiEK96xA95gbjPa1bg@mail.gmail.com \
    --to=brendan.d.gregg@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    /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).