Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get complete stack dump from profiler in every sample for use in flame graph?

I really like the idea of the Flame Graph for profiling since it will help in eliminating unneeded function calls. There is a catch however in that it requires the profiler to do a complete stack dump each time it collects a sample. This can be accomplished with DTrace or SystemTap quite easily, but I need to be able to do this on an ARM device running ubuntu (which eliminates DTrace). I would also like to do this without recompiling the kernel (which eliminates SystemTap).

Is it possible to get Valgrind/Callgrind or OProfile (or some other profiling tool that can run on an ARM device in Ubuntu) to output something similar to:
dtrace -n 'profile-1001 /pid == 12345 && arg1/ { @[ustack()] = count(); }

like image 330
Leo Avatar asked Oct 22 '25 09:10

Leo


1 Answers

Try Linux perf_events (aka the "perf" command), which is part of the mainline Linux kernel, and usually installed via the linux-tools-common (or similar) package. I often use it to create flame graphs on Linux.

I wrote up some instructions for creating flame graphs with perf on: http://www.brendangregg.com/perf.html#FlameGraphs

like image 104
Brendan Gregg Avatar answered Oct 25 '25 00:10

Brendan Gregg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!