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 -- To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html