Skip to content
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

Improve profile builder performance #437

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/lib/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,13 @@ export class Profile {
}

export class StackListProfileBuilder extends Profile {
_appendSample(stack: FrameInfo[], weight: number, useAppendOrder: boolean) {
_appendSample(stack: Frame[], weight: number, useAppendOrder: boolean) {
if (isNaN(weight)) throw new Error('invalid weight')
let node = useAppendOrder ? this.appendOrderCalltreeRoot : this.groupedCalltreeRoot

let framesInStack = new Set<Frame>()

for (let frameInfo of stack) {
const frame = Frame.getOrInsert(this.frames, frameInfo)
for (let frame of stack) {
const last = useAppendOrder
? lastOf(node.children)
: node.children.find(c => c.frame === frame)
Expand Down Expand Up @@ -500,8 +499,9 @@ export class StackListProfileBuilder extends Profile {
throw new Error('Samples must have positive weights')
}

this._appendSample(stack, weight, true)
this._appendSample(stack, weight, false)
const frames = stack.map(fr => Frame.getOrInsert(this.frames, fr))
this._appendSample(frames, weight, true)
this._appendSample(frames, weight, false)
}

private pendingSample: {
Expand Down