SamSaffron / flamegraph

Flamegraph profiling support for Ruby 2.0
MIT License
382 stars 36 forks source link

Fix same node columns with different parents #25

Open thisduck opened 7 years ago

thisduck commented 7 years ago

Hey @SamSaffron,

Opening a different pull request for this issue. I'll be merging it into #24 soon.

The case is when a node is wider than it's parent. This happens when both method1 and method2 call method3. If method1 is 3 samples and method2 is 2 samples, method3 appears as a node with 5 samples.

method3 should appear as two nodes, first with 3 samples and as a child of method1. And then with 2 samples and as a child of method2.

This PR fixes that scenario. I modified the tests and added a new one to cover a slightly different case.

I had originally fixed this in the javascript as part of #24, but for very large datasets (over 50MB) the javascript crashes because it has to modify the processed data. It's much faster to do on the ruby side. Creating a PR off of master to isolate the issue.