The Differential Flame Graph was introduced by Brendan Gregg in FlameGraph toolkit , which can let us debug the performance regressions. But it also has its known issue.
“If code paths vanish completely in the second profile, then there’s nothing to color blue.”
For me there is another issue.
The width of frame doesn’t present the REAL difference between two flame graphs.
Let’s see an example🌰.
Assume we have two folded files like below:
1 | before.folded |
To get a clear view for function changes, we can put it in a table like below:
Name | Before | After | Delta |
---|---|---|---|
func1 | 5 | 0 | -5 |
func2 | 10 | 35 | +25 |
func3 | 8 | 18 | +10 |
func4 | 25 | 0 | -25 |
func5 | 6 | 20 | +14 |
func6 | 15 | 5 | -10 |
func7 | 0 | 7 | +7 |
Total | 69 | 86 | |96| |
Original Differential Flame Graph
func1
was totally lost. Although we can use Negation to get another differential flame graph.func3
have +10 delta andfunc4
have down to zero with -25 delta. But they share the SAME frame width because the diff-graph is just based onafter.folded
.
Differential Flame Graph With Delta Width
I changed the way calculate diff-frame width which is based on Delta
column in the above table, cause it’s REAL differentials. Here is the screenshot.
The width of frame is based on delta, not any one of samples. So the width percentage is stand for: How much does it effects in all changes. Now,
func1
shows up andfunc4
has outstanding optimization from the view.The frame color is calculated by its OWN delta. So it means: How does the frame’s SELF samples(time) changes.
- For the function has not real samples, I put the total delta width on the hint message.
Try it
You can try the improved differential flame graph at my fork from the Rust🦀 version of flame graph toolkit inferno(which is 💥20x faster than Perl version).