-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix algorithm for FlameGraphs: top-down walk of tree, hitting every node
Before, starting from leaves up, we would miss the exclusive time for parent frames that take longer than their children. Now, we walk from top-down, and record a span in these four cases: - If the node is a leaf - If there is a gap _before_ first child - If there is a gap _between_ children - If there is a gap _after_ the last child Then for each span, we walk *back* up the tree (😅) and record the stack trace. We could maybe be algorithmically more efficient with some thought? We could certainly be a constant factor more efficient. My main concern is walking down each node and then back up each stack, this might be O(n*h) where h is the height of the tree. Probably would be better to build this up as we go? But 🤷 we have to emit the whole stack every time, so I don't think there's any avoiding O(n*h) time.
- Loading branch information
Showing
1 changed file
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters