jonhoo / inferno

A Rust port of FlameGraph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to not merge children counts into parents

Mark-Simulacrum opened this issue · comments

For example, with the input of

a;b 1
a 3

I would expect 2 nodes in the output:

  • a with width 3
  • b with width 1

Inferno, however, will currently produce a with count 4 (double counting the children). I'm working with a data source that is based on a tracing profiler, so the input is a stream of events (start, end) -- as such, a for me includes the time taken by b already.

The workaround, of course, is to call into inferno with subtracted stacks before hand (i.e., pass in a 2 in the example above). This is possible and not too hard, but seems like needless work.

Ah, yes, the assumption that each stack is a distinct "deep" sample (meaning a does not include samples at a;b) is made throughout flamegraph, and therefore throughout inferno. Working around this will be a bit of a pain.

If we wanted to provide this as an option, I think what you'd want to do is modify how the end time for each frame is computed on the way "down" the stack here:

end_time: time,

That is, when we finish a frame (i.e., when we set its end time), subtract the time of all of its child frames from that end time.

An alternative would be to do this in a second pass over frames somewhere around here

I'm not sure which one will be simpler.

I think if this is a deeply embedded assumption then it makes sense for me to continue doing this in code calling into inferno, where it's pretty trivial. I'm going to go ahead and close this.

There are a number of things that the upstream Perl flamegraph does that I would probably not have done if I was building this from scratch. But since compatibility with the existing tool seemed pretty important, its assumptions ended up being encoded in inferno as well. Maybe one day we'll break from that :)