Skip to content

Commit

Permalink
When stackcollapsing Instruments output, capture the "Self" value rat…
Browse files Browse the repository at this point in the history
…her than the "Running Time" value.

This fixes an issue of cascading call times that caused the flamegraph output to incorrectly visually represent the time spent in all parts of the stack.

This bug can be reproduced in practice but clearly seen in the example posted on https://schani.wordpress.com/2012/11/16/flame-graphs-for-instruments/.
I suspect in that example the time spent in "mono_gc_alloc_obj" is actually fairly similar to that in "collect_nursery", however the output reflects a 142:66 ratio.

This issue is caused because flamegraph.pl expects individual time/samples within single stack frames, not a total value for all child stack frames.

The 3rd "Self" value in the Instruments output is the former, so swapping to that value reflects visually the correct time spent in each stack frame.
  • Loading branch information
Marc Di Luzio committed Apr 14, 2015
1 parent d5e8b8e commit 03fc2ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stackcollapse-instruments.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<>;
foreach (<>) {
chomp;
/(\d+)\.\d+ms[^,]+,\d+,\s+,(\s*)(.+)/ or die;
/\d+\.\d+ms[^,]+,(\d+),\s+,(\s*)(.+)/ or die;
my $func = $3;
my $depth = length ($2);
$stack [$depth] = $3;
Expand Down

0 comments on commit 03fc2ea

Please sign in to comment.