Skip to content

Commit c0d937f

Browse files
Fix opcode merging in inverted flamegraph view
Opcodes from multiple call paths were silently dropped, only the first path's opcodes were kept. Now they're summed correctly when nodes merge.
1 parent afe2f4e commit c0d937f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/profiling/sampling/_flamegraph_assets/flamegraph.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ function accumulateInvertedNode(parent, stackFrame, leaf, isDifferential) {
12761276
lineno: stackFrame.lineno,
12771277
funcname: stackFrame.funcname,
12781278
source: stackFrame.source,
1279-
opcodes: stackFrame.opcodes,
1279+
opcodes: null,
12801280
threads: new Set()
12811281
};
12821282

@@ -1296,6 +1296,15 @@ function accumulateInvertedNode(parent, stackFrame, leaf, isDifferential) {
12961296
if (leaf.threads) {
12971297
leaf.threads.forEach(t => node.threads.add(t));
12981298
}
1299+
if (stackFrame.opcodes) {
1300+
if (!node.opcodes) {
1301+
node.opcodes = { ...stackFrame.opcodes };
1302+
} else {
1303+
for (const [op, count] of Object.entries(stackFrame.opcodes)) {
1304+
node.opcodes[op] = (node.opcodes[op] || 0) + count;
1305+
}
1306+
}
1307+
}
12991308

13001309
if (isDifferential) {
13011310
node.baseline += stackFrame.baseline || 0;

0 commit comments

Comments
 (0)