jonhoo / inferno

A Rust port of FlameGraph
Other
1.68k stars 125 forks source link

Color diffusion mode gives less useful results in flamechart mode #272

Open itamarst opened 2 years ago

itamarst commented 2 years ago

Consider the following profiling result:

bottleneck 20
interlude 20
bottleneck 20
interlude 20
bottleneck 20

In flamegraph mode with --colordiffusion, the bottleneck is darker red, since it is 60% of time spent vs 40%:

Screenshot from 2022-10-30 08-57-01

In flamechart mode, however, the segments all have the same red saturation:

Screenshot from 2022-10-30 08-57-30

Insofar as the goal of the color mode is to highlight more significant parts of the code, this is wrong: the relative saturation should be the same as in the flamegraph. Just because the bottleneck is chopped up doesn't mean it has ceased to be the bottleneck, it should still be redder.

jonhoo commented 2 years ago

I agree, although I also suspect this'll be quite tricky to fix in chart mode. You'd need a sort of two-pass thing where we first scan for how expensive each function is in aggregate (by basically doing a non-chart plot and now drawing it), and then carrying that information forward into chart mode.

itamarst commented 2 years ago

Yeah, or a trie-like thing.