linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* perf report feature request: folded stack output
@ 2015-10-09 21:24 Brendan Gregg
  2015-10-09 22:13 ` Brendan Gregg
  2015-10-09 23:33 ` Milian Wolff
  0 siblings, 2 replies; 4+ messages in thread
From: Brendan Gregg @ 2015-10-09 21:24 UTC (permalink / raw)
  To: linux-perf-use.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-21  0:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).