spiermar / d3-flame-graph

A D3.js plugin that produces flame graphs from hierarchical data.
Apache License 2.0
890 stars 119 forks source link

--reverse option #97

Open leventov opened 6 years ago

leventov commented 6 years ago

It would be nice to support an equivalent of the original flamegraph's --reverse option: see https://github.com/brendangregg/FlameGraph/blob/a8d807a11c0f22871134324bda709618ca482b58/flamegraph.pl#L119.

It's not the same ask as #73, which is turning the graph upside down, but changing the principle of stack summation.

leogomes commented 6 years ago

+1 @spiermar: If you can provide some directions, I may be able to give it a try.

spiermar commented 6 years ago

This mostly involves changing of the data structure the plugin is rendering, not how it's rendering it, so I rather keep this feature in the tools that parse the stacks and generate the callgraph, instead of the d3 plugin. I might be wrong, but without looking too deep into the code, I don't even think it's possible to generate the --reverse callgraph out of the original callgraph. There's no way of knowing how much of a parent's value is in the same stack as the child's. You need the original profile to generate that. Thoughts @leventov @leogomes ?

spiermar commented 6 years ago

It could be documented example about how to create the reversed flame graph out of the original profile. Could also be a feature on burn.

shaunlebron commented 2 years ago

The author of the original flamegraph mentioned this back in #22 and a few other times:

From here:

Netflix has been developing d3-flame-graph,12 which includes transitions when zooming. The hope is that this can provide new interactivity features, including a way to toggle the merge order from bottom-up to top-down, and also to merge around a given function.

And here:

I've been supporting a rewrite of flame graphs in d3, as it can support changing merge orders live without having to regenerate the flame graph as with my Perl program.

Also related, the “Sandwich View” in speedscope is a kind of in-between merge option, merging “out” from a selected function instead of up from the root or down from the leaves: