How do flame graphs handle the case where most of the time is spent in some leaf function that is called from all over the program? In this case, each individual stack would not take much time but in aggregate, a lot of time is spent in the function at the top of all of the call stacks. This should not be that uncommon to have hotspots in things like copying routines, compression, encryption etc that are not associated with any particular stack.<p>pprof from <a href="https://github.com/google/pprof">https://github.com/google/pprof</a> can produce a DAG view of a profile where nodes are sized proportional to their cumulative time, e.g.,
<a href="https://slcjordan.github.io/images/pprof/graphviz.png" rel="nofollow">https://slcjordan.github.io/images/pprof/graphviz.png</a> and such a view would seem to cover the case above and subsume the usual use cases for a flame graph, would it not?<p>Although I guess a flat text profile of functions sorted by time would also highlight these kinds of hot spots. Still, if we want a single graphical view as a go-to, it's not clear that flame graphs are all that much better than pprof DAGs.
Just to advertise the perf tool has inbuilt flamegraph generation code these days (well leaning on D3.js). So `perf script report flamegraph` will convert a perf.data file into a flamegraph.html. Similarly there is `perf script report gecko` to write out the firefox profiler's json format.
OK, shameful confession time here: I just <i>cannot</i> grasp flame charts, no matter how hard I try. And yes: that's just me, I'm dumb, etc. etc. (and I freely admit all of that, including the et-ceteras!)<p>I tried to follow along with things that are relevant to my job, like <a href="https://randomascii.wordpress.com/2016/09/05/etw-flame-graphs-made-easy/" rel="nofollow">https://randomascii.wordpress.com/2016/09/05/etw-flame-graph...</a> ...And totally failed? I look at the reddest part of the chart, I look at the peaks, and none of that matches the conclusion reached in the blog post?<p>And then I tried to grok all the knowledge conveyed in <a href="https://www.brendangregg.com/flamegraphs.html" rel="nofollow">https://www.brendangregg.com/flamegraphs.html</a> and... came away similarly confused? Sure, I see patterns, but when asked to identify which of those patterns indicate problems, I would still score <50%?<p>And, I mean, I do memory/CPU traces like all day every day, and I fix code all the time based on that, but that's all just based on hierarchical bar charts, which are NOT the same as inverted flame graphs, as far as I can tell?<p>Anyway, thanks for coming to my therapy session, and feel free to leave your helpful-comment-that-will-finally-enlighten-me and/or downvote at the door.
Back in 2018, I built a flame graph generator for AppDynamics APM-captured snapshots which are traces of call stacks captured over execution time with stack frame timing. Those would typically come from java or clr, although other types like node and ruby and php were also supported.<p>My tool could handle one snapshot or hundreds of thousands of them and it was more useful to aggregate many snapshots I used on Brandan Gregg perl script implementation as reference but wrote all the code myself from scratch to produce just what I wanted. One of the more key things I felt was different was was adding color coding of the TYPE of the call frame based off the code namespace - like green for Oracle jdbc driver or blue for websphere entry or light azure for the clr internals. With multiple contrasting colors one could see the important transitions from own code to library code and back to own code.<p>It was one of the most fun coding challenges I've ever done. Pretty much the only time I had to refactor recursion into stack because some of the call graphs (looking at you java) were so ridiculously deep<p><a href="https://github.com/Appdynamics/AppDynamics.DEXTER/wiki/Flame-Graph-Report">https://github.com/Appdynamics/AppDynamics.DEXTER/wiki/Flame...</a>
Do colors have any significance in those flame graphs? It's unfortunate that a post about them does not mention anything about colors. If you look at at the examples, there are bars, which have the same length, but the colors look random to me.
For C++ applications, nothing beats Tracy’s flame graphs in value per dollar. We are using it at Adobe with great effect. It can handle mutex lock contention, runtime values and notes, arbitrary value graphs, and more. Highly recommended: <a href="https://github.com/wolfpld/tracy">https://github.com/wolfpld/tracy</a>