-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flamegraph: Update threshold for collapsing and fix flickering #78206
Conversation
useEffect(() => { | ||
if (data) { | ||
setCollapsedMap(data.getCollapsedMap()); | ||
|
||
let levels = data.getLevels(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of useMap for the collapseMap and separate useEffect for the levels computation this is done in single effect which synchronizes those 2 values and prevent flickering on double rerenders.
@@ -82,22 +77,6 @@ export function nestedSetToLevels( | |||
level: currentLevel, | |||
}; | |||
|
|||
if (options?.collapsing) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was moved to separate class for easier testing and also the whole logic was moved to after whole tree is computed. Otherwise we could not use any heuristic about how many children a parent can have as we don't have all the children at this point of the code.
} | ||
} | ||
|
||
addTree(root: LevelItem) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we need to know how many children item has we need to wait for the whole tree to be done and than do another pass over it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
What is this feature?
Before the collapsing groups in flamegraph were done only in cases parent and child had the same value. This was pretty strict and with lot's of samples even very thin wrapper code could accrue some difference in value so this changes the default threshold to min 0.99 of the parent.
Also this synchronizes the creation of the collapse map and other data so that the flamegraph is rendered with the collapsed groups on first render.
Why do we need this feature?
[Add a description of the problem the feature is trying to solve.]
Who is this feature for?
[Add information on what kind of user the feature is for.]
Which issue(s) does this PR fix?:
Fixes #
Special notes for your reviewer:
Please check that: