-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
feat(profiling): move flamegraph and differential flamegraph #30910
Conversation
6bbc00f
to
cf99f30
Compare
a5521ea
to
197c99d
Compare
size-limit report
|
const counts = new Map<string, number>(); | ||
|
||
for (const frame of frames) { | ||
const key = frame.frame.name + (frame.frame.file ? frame.frame.file : ''); |
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.
Should this be a method on Frame
?
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.
@Zylphrex I thought about it before, but I haven't done it. The reason for that is that this is more the key that we use for color encoding which is not something that the Frame has to know or care about. Maybe a utility fn would be a good middle ground here, wdyt?
this.configSpace = new Rect(0, 0, this.duration, this.depth); | ||
} else { | ||
// If we have no frames, set the trace duration to 1 second so that we can render a placeholder grid | ||
this.configSpace = new Rect(0, 0, 1_000_000, 0); |
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.
Are the units always going to be microseconds
? I see that it's possible to specify a unit in Profile
. Should that be used to compute this value?
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.
Ah correct, we need to set that too, I missed that 🙏🏼
e016734
to
b179054
Compare
b179054
to
24788b6
Compare
Port over the main flamegraph and differential flamegraph classes.
The two classes are used to build (not rendering) the flamegraph in different ways (see buildCallOrderGraph and buildLeftHeavyGraph). They are mainly responsible for outputting an array of frames to render and giving us a configuration view (usually at x:0, y:0, width: timeline duration, height: max stack height).
There are two main functions to look at - buildLeftHeavyGraph and buildCallOrderGraph.
They both iterate over all frames of a profile and append the frames to render to
this.frames
with the slight difference that buildLeftHeavyGraph sorts the tree first (depth first) and updates the frames startTime and endTime based on their new positions so that startTime is the sum of all child frames preceding the current frame.e.g. left heavy timings change
Note that the order of this.frames doesn't matter and it will be up to whoever consumes the flamegraph to determine what and when to render.