Support importing multithreaded profiles from Chrome 66 (#206)
In #194, I added code to support import of multithreaded profiles from Chrome 70. I'm now doing some profiling work on an older version of Android chrome, and it seems like the profile objects don't yet have `id` properties. Instead, we should try using the `pid/tid` pair to identify profiles when the `id` field is absent. This was tested against a profile import from Android Chrome 66.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -515,6 +515,408 @@ exports[`importFromChromeTimeline Chrome 69: indexToView 1`] = `0`;
|
||||
|
||||
exports[`importFromChromeTimeline Chrome 69: profileGroup.name 1`] = `"simple.json"`;
|
||||
|
||||
exports[`importFromChromeTimeline Workers Chrome 66 1`] = `
|
||||
Object {
|
||||
"frames": Array [
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "(program)::-1:-1",
|
||||
"line": -1,
|
||||
"name": "(program)",
|
||||
"selfWeight": 819120,
|
||||
"totalWeight": 819120,
|
||||
},
|
||||
Frame {
|
||||
"col": 20,
|
||||
"file": "http://172.30.3.176:7777/worker.js",
|
||||
"key": "onmessage:http://172.30.3.176:7777/worker.js:14:20",
|
||||
"line": 14,
|
||||
"name": "onmessage",
|
||||
"selfWeight": 639,
|
||||
"totalWeight": 857719,
|
||||
},
|
||||
Frame {
|
||||
"col": 14,
|
||||
"file": "http://172.30.3.176:7777/worker.js",
|
||||
"key": "alpha:http://172.30.3.176:7777/worker.js:8:14",
|
||||
"line": 8,
|
||||
"name": "alpha",
|
||||
"selfWeight": 19976,
|
||||
"totalWeight": 835149,
|
||||
},
|
||||
Frame {
|
||||
"col": 14,
|
||||
"file": "http://172.30.3.176:7777/worker.js",
|
||||
"key": "gamma:http://172.30.3.176:7777/worker.js:0:14",
|
||||
"line": 0,
|
||||
"name": "gamma",
|
||||
"selfWeight": 22197,
|
||||
"totalWeight": 30000,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "postMessage::-1:-1",
|
||||
"line": -1,
|
||||
"name": "postMessage",
|
||||
"selfWeight": 1278,
|
||||
"totalWeight": 21931,
|
||||
},
|
||||
],
|
||||
"name": "worker.json - DedicatedWorker thread",
|
||||
"stacks": Array [
|
||||
" 9.07ms",
|
||||
"(program) 5.49ms",
|
||||
"onmessage;alpha;gamma 3.69ms",
|
||||
"onmessage;postMessage 212.00µs",
|
||||
"onmessage;postMessage;(program) 3.97ms",
|
||||
"onmessage;alpha;gamma 3.82ms",
|
||||
"onmessage;postMessage 414.00µs",
|
||||
"onmessage;postMessage;(program) 3.71ms",
|
||||
"onmessage;alpha;gamma 1.13ms",
|
||||
"onmessage 188.00µs",
|
||||
"onmessage;alpha;gamma 2.48ms",
|
||||
"onmessage;alpha;gamma;(program) 3.89ms",
|
||||
"onmessage;alpha;gamma 373.00µs",
|
||||
"onmessage;alpha 184.00µs",
|
||||
"onmessage;alpha;gamma 3.36ms",
|
||||
"onmessage;alpha;gamma;(program) 3.91ms",
|
||||
"onmessage;alpha;gamma 3.94ms",
|
||||
"onmessage;postMessage 205.00µs",
|
||||
"onmessage;postMessage;(program) 3.91ms",
|
||||
"onmessage 451.00µs",
|
||||
"onmessage;alpha;gamma 566.00µs",
|
||||
"onmessage;alpha 194.00µs",
|
||||
"onmessage;alpha;gamma 2.09ms",
|
||||
"onmessage;alpha 189.00µs",
|
||||
"onmessage;alpha;gamma 746.00µs",
|
||||
"onmessage;postMessage 211.00µs",
|
||||
"onmessage;postMessage;(program) 4.00ms",
|
||||
"onmessage;alpha 4.80ms",
|
||||
"onmessage;alpha;(program) 5.28ms",
|
||||
"onmessage;alpha 4.70ms",
|
||||
"onmessage;postMessage 236.00µs",
|
||||
"onmessage;postMessage;(program) 5.06ms",
|
||||
"onmessage;alpha 5.07ms",
|
||||
"onmessage;alpha;(program) 4.81ms",
|
||||
"onmessage;alpha 4.84ms",
|
||||
"onmessage;alpha;(program) 775.08ms",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`importFromChromeTimeline Workers Chrome 66 2`] = `
|
||||
Object {
|
||||
"frames": Array [
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "(program)::-1:-1",
|
||||
"line": -1,
|
||||
"name": "(program)",
|
||||
"selfWeight": 106601,
|
||||
"totalWeight": 108131,
|
||||
},
|
||||
Frame {
|
||||
"col": 8,
|
||||
"file": "",
|
||||
"key": "(anonymous)::247:8",
|
||||
"line": 247,
|
||||
"name": "(anonymous)",
|
||||
"selfWeight": 551,
|
||||
"totalWeight": 2766,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "addEventListener::-1:-1",
|
||||
"line": -1,
|
||||
"name": "addEventListener",
|
||||
"selfWeight": 178,
|
||||
"totalWeight": 2215,
|
||||
},
|
||||
Frame {
|
||||
"col": 17,
|
||||
"file": "",
|
||||
"key": "onLoaded::866:17",
|
||||
"line": 866,
|
||||
"name": "onLoaded",
|
||||
"selfWeight": 372,
|
||||
"totalWeight": 5158,
|
||||
},
|
||||
Frame {
|
||||
"col": 0,
|
||||
"file": "",
|
||||
"key": "(anonymous)::0:0",
|
||||
"line": 0,
|
||||
"name": "(anonymous)",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 25649,
|
||||
},
|
||||
Frame {
|
||||
"col": 17,
|
||||
"file": "",
|
||||
"key": "dispatch::845:17",
|
||||
"line": 845,
|
||||
"name": "dispatch",
|
||||
"selfWeight": 1103,
|
||||
"totalWeight": 25649,
|
||||
},
|
||||
Frame {
|
||||
"col": 20,
|
||||
"file": "",
|
||||
"key": "setPlatform::839:20",
|
||||
"line": 839,
|
||||
"name": "setPlatform",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 902,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "add::-1:-1",
|
||||
"line": -1,
|
||||
"name": "add",
|
||||
"selfWeight": 521,
|
||||
"totalWeight": 902,
|
||||
},
|
||||
Frame {
|
||||
"col": 14,
|
||||
"file": "",
|
||||
"key": "reset::433:14",
|
||||
"line": 433,
|
||||
"name": "reset",
|
||||
"selfWeight": 911,
|
||||
"totalWeight": 2438,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "getContext::-1:-1",
|
||||
"line": -1,
|
||||
"name": "getContext",
|
||||
"selfWeight": 598,
|
||||
"totalWeight": 598,
|
||||
},
|
||||
Frame {
|
||||
"col": 20,
|
||||
"file": "",
|
||||
"key": "resetCanvas::423:20",
|
||||
"line": 423,
|
||||
"name": "resetCanvas",
|
||||
"selfWeight": 370,
|
||||
"totalWeight": 553,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "scale::-1:-1",
|
||||
"line": -1,
|
||||
"name": "scale",
|
||||
"selfWeight": 183,
|
||||
"totalWeight": 183,
|
||||
},
|
||||
Frame {
|
||||
"col": 8,
|
||||
"file": "http://172.30.3.176:7777/worker.html",
|
||||
"key": "(anonymous):http://172.30.3.176:7777/worker.html:0:8",
|
||||
"line": 0,
|
||||
"name": "(anonymous)",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 2591,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "Worker::-1:-1",
|
||||
"line": -1,
|
||||
"name": "Worker",
|
||||
"selfWeight": 873,
|
||||
"totalWeight": 2591,
|
||||
},
|
||||
Frame {
|
||||
"col": 29,
|
||||
"file": "http://172.30.3.176:7777/worker.html",
|
||||
"key": "worker.onmessage:http://172.30.3.176:7777/worker.html:19:29",
|
||||
"line": 19,
|
||||
"name": "worker.onmessage",
|
||||
"selfWeight": 1221,
|
||||
"totalWeight": 60859,
|
||||
},
|
||||
Frame {
|
||||
"col": 16,
|
||||
"file": "http://172.30.3.176:7777/worker.html",
|
||||
"key": "apple:http://172.30.3.176:7777/worker.html:9:16",
|
||||
"line": 9,
|
||||
"name": "apple",
|
||||
"selfWeight": 5474,
|
||||
"totalWeight": 58863,
|
||||
},
|
||||
Frame {
|
||||
"col": 17,
|
||||
"file": "http://172.30.3.176:7777/worker.html",
|
||||
"key": "banana:http://172.30.3.176:7777/worker.html:1:17",
|
||||
"line": 1,
|
||||
"name": "banana",
|
||||
"selfWeight": 50635,
|
||||
"totalWeight": 53816,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "postMessage::-1:-1",
|
||||
"line": -1,
|
||||
"name": "postMessage",
|
||||
"selfWeight": 348,
|
||||
"totalWeight": 348,
|
||||
},
|
||||
Frame {
|
||||
"col": -1,
|
||||
"file": "",
|
||||
"key": "(garbage collector)::-1:-1",
|
||||
"line": -1,
|
||||
"name": "(garbage collector)",
|
||||
"selfWeight": 1530,
|
||||
"totalWeight": 1530,
|
||||
},
|
||||
],
|
||||
"name": "worker.json - CrRendererMain",
|
||||
"stacks": Array [
|
||||
" 28.66ms",
|
||||
"(program) 315.00µs",
|
||||
" 108.00µs",
|
||||
"(program) 433.00µs",
|
||||
" 116.00µs",
|
||||
"(program) 436.00µs",
|
||||
" 368.00µs",
|
||||
"(program) 108.00µs",
|
||||
" 30.76ms",
|
||||
"(program) 1.48ms",
|
||||
" 167.00µs",
|
||||
"(program) 1.68ms",
|
||||
" 6.96ms",
|
||||
"(program) 2.03ms",
|
||||
" 4.64ms",
|
||||
"(program) 3.86ms",
|
||||
" 14.05ms",
|
||||
"(program) 15.35ms",
|
||||
"(anonymous) 551.00µs",
|
||||
"(anonymous);addEventListener 178.00µs",
|
||||
"(anonymous);addEventListener;(program) 2.04ms",
|
||||
"onLoaded 372.00µs",
|
||||
"onLoaded;(program) 4.79ms",
|
||||
"(anonymous);dispatch;setPlatform;add 521.00µs",
|
||||
"(anonymous);dispatch;setPlatform;add;(program) 381.00µs",
|
||||
"(anonymous);dispatch 927.00µs",
|
||||
"(anonymous);dispatch;reset 185.00µs",
|
||||
"(anonymous);dispatch;reset;getContext 598.00µs",
|
||||
"(anonymous);dispatch;reset 131.00µs",
|
||||
"(anonymous);dispatch;reset;resetCanvas 370.00µs",
|
||||
"(anonymous);dispatch;reset;resetCanvas;scale 183.00µs",
|
||||
"(anonymous);dispatch;reset 595.00µs",
|
||||
"(anonymous);dispatch;reset;(program) 376.00µs",
|
||||
"(anonymous);dispatch 176.00µs",
|
||||
"(anonymous);dispatch;(program) 21.21ms",
|
||||
" 606.00µs",
|
||||
"(program) 11.20ms",
|
||||
" 296.00µs",
|
||||
"(program) 1.90ms",
|
||||
"(anonymous);Worker 873.00µs",
|
||||
"(anonymous);Worker;(program) 1.72ms",
|
||||
" 670.00µs",
|
||||
"(program) 28.45ms",
|
||||
" 353.00µs",
|
||||
"(program) 187.00µs",
|
||||
" 185.00µs",
|
||||
"(program) 4.29ms",
|
||||
" 607.00µs",
|
||||
"(program) 192.00µs",
|
||||
" 407.00µs",
|
||||
"(program) 215.00µs",
|
||||
" 28.98ms",
|
||||
"(program) 770.00µs",
|
||||
"worker.onmessage;apple 185.00µs",
|
||||
"worker.onmessage;apple;banana 180.00µs",
|
||||
"worker.onmessage;apple 367.00µs",
|
||||
"worker.onmessage;apple;banana 182.00µs",
|
||||
"worker.onmessage;apple 183.00µs",
|
||||
"worker.onmessage;apple;banana 546.00µs",
|
||||
"worker.onmessage;apple 365.00µs",
|
||||
"worker.onmessage;apple;banana 182.00µs",
|
||||
"worker.onmessage;apple 365.00µs",
|
||||
"worker.onmessage;apple;banana 188.00µs",
|
||||
"worker.onmessage;apple 912.00µs",
|
||||
"worker.onmessage;apple;banana 189.00µs",
|
||||
"worker.onmessage;apple 2.51ms",
|
||||
"worker.onmessage;apple;banana 8.48ms",
|
||||
"worker.onmessage;postMessage 170.00µs",
|
||||
" 3.95ms",
|
||||
"worker.onmessage;apple;banana 433.00µs",
|
||||
"worker.onmessage 187.00µs",
|
||||
"worker.onmessage;apple;banana 3.30ms",
|
||||
" 3.90ms",
|
||||
"(program) 187.00µs",
|
||||
"worker.onmessage;apple;banana 1.47ms",
|
||||
"worker.onmessage;apple 187.00µs",
|
||||
"worker.onmessage;apple;banana 2.05ms",
|
||||
" 4.01ms",
|
||||
"worker.onmessage;apple;banana 3.77ms",
|
||||
"worker.onmessage;postMessage 178.00µs",
|
||||
" 3.87ms",
|
||||
"worker.onmessage;apple;banana 3.74ms",
|
||||
"worker.onmessage 233.00µs",
|
||||
" 3.88ms",
|
||||
"(program) 187.00µs",
|
||||
"worker.onmessage;apple;banana 744.00µs",
|
||||
"worker.onmessage;apple 196.00µs",
|
||||
"worker.onmessage;apple;banana 2.08ms",
|
||||
"worker.onmessage 188.00µs",
|
||||
"worker.onmessage;apple;banana 582.00µs",
|
||||
" 4.46ms",
|
||||
"(program) 187.00µs",
|
||||
"worker.onmessage;apple;banana 3.84ms",
|
||||
"worker.onmessage;apple;banana;(program) 278.00µs",
|
||||
" 4.76ms",
|
||||
"worker.onmessage;apple;banana 5.01ms",
|
||||
"worker.onmessage;apple;banana;(program) 214.00µs",
|
||||
" 4.67ms",
|
||||
"(program) 193.00µs",
|
||||
"worker.onmessage;apple;banana 2.44ms",
|
||||
"worker.onmessage 186.00µs",
|
||||
"worker.onmessage;apple;banana 1.02ms",
|
||||
"worker.onmessage;banana 209.00µs",
|
||||
"worker.onmessage;apple;banana 207.00µs",
|
||||
"worker.onmessage;apple 207.00µs",
|
||||
"worker.onmessage;apple;banana 634.00µs",
|
||||
"worker.onmessage;apple;banana;(program) 237.00µs",
|
||||
" 4.92ms",
|
||||
"worker.onmessage;apple;banana 3.05ms",
|
||||
"worker.onmessage;banana 218.00µs",
|
||||
"worker.onmessage;apple;banana 876.00µs",
|
||||
"worker.onmessage 219.00µs",
|
||||
"worker.onmessage;apple;banana 219.00µs",
|
||||
"worker.onmessage;apple;banana;(program) 706.00µs",
|
||||
" 4.40ms",
|
||||
"worker.onmessage;apple;banana 2.71ms",
|
||||
"worker.onmessage 208.00µs",
|
||||
"worker.onmessage;apple;banana 2.08ms",
|
||||
"worker.onmessage;apple;banana;(program) 216.00µs",
|
||||
"worker.onmessage;apple;banana;(program);(garbage collector) 1.53ms",
|
||||
" 469.53ms",
|
||||
"(program) 382.00µs",
|
||||
" 262.13ms",
|
||||
"(program) 200.00µs",
|
||||
" 4.51ms",
|
||||
"(program) 221.00µs",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`importFromChromeTimeline Workers Chrome 66: indexToView 1`] = `1`;
|
||||
|
||||
exports[`importFromChromeTimeline Workers Chrome 66: profileGroup.name 1`] = `"worker.json"`;
|
||||
|
||||
exports[`importFromChromeTimeline Workers Chrome 70 1`] = `
|
||||
Object {
|
||||
"frames": Array [
|
||||
|
||||
@@ -16,6 +16,10 @@ test('importFromV8Profiler Node 10', async () => {
|
||||
await checkProfileSnapshot('./sample/profiles/node/10.11.0/example.cpuprofile')
|
||||
})
|
||||
|
||||
test('importFromChromeTimeline Workers Chrome 66', async () => {
|
||||
await checkProfileSnapshot('./sample/profiles/Chrome/66/worker.json')
|
||||
})
|
||||
|
||||
test('importFromChromeTimeline Workers Chrome 70', async () => {
|
||||
await checkProfileSnapshot('./sample/profiles/Chrome/70/worker.json')
|
||||
})
|
||||
|
||||
+9
-12
@@ -79,19 +79,17 @@ export function importFromChromeTimeline(events: TimelineEvent[], fileName: stri
|
||||
// that they are.
|
||||
sortBy(events, e => e.ts)
|
||||
|
||||
const DEFAULT_ID = '(default id)'
|
||||
|
||||
for (let event of events) {
|
||||
if (event.name === 'CpuProfile') {
|
||||
cpuProfileByID.set(event.id || DEFAULT_ID, event.args.data.cpuProfile as CPUProfile)
|
||||
|
||||
if (event.id) {
|
||||
pidTidById.set(event.id, `${event.pid}:${event.tid}`)
|
||||
}
|
||||
const pidTid = `${event.pid}:${event.tid}`
|
||||
const id = event.id || pidTid
|
||||
cpuProfileByID.set(id, event.args.data.cpuProfile as CPUProfile)
|
||||
pidTidById.set(id, pidTid)
|
||||
}
|
||||
|
||||
if (event.name === 'Profile') {
|
||||
cpuProfileByID.set(event.id || DEFAULT_ID, {
|
||||
const pidTid = `${event.pid}:${event.tid}`
|
||||
cpuProfileByID.set(event.id || pidTid, {
|
||||
startTime: 0,
|
||||
endTime: 0,
|
||||
nodes: [],
|
||||
@@ -110,7 +108,8 @@ export function importFromChromeTimeline(events: TimelineEvent[], fileName: stri
|
||||
}
|
||||
|
||||
if (event.name === 'ProfileChunk') {
|
||||
const cpuProfile = cpuProfileByID.get(event.id || DEFAULT_ID)
|
||||
const pidTid = `${event.pid}:${event.tid}`
|
||||
const cpuProfile = cpuProfileByID.get(event.id || pidTid)
|
||||
if (cpuProfile) {
|
||||
const chunk = event.args.data
|
||||
if (chunk.cpuProfile) {
|
||||
@@ -131,9 +130,7 @@ export function importFromChromeTimeline(events: TimelineEvent[], fileName: stri
|
||||
cpuProfile.endTime = chunk.endTime
|
||||
}
|
||||
} else {
|
||||
console.warn(
|
||||
`Ignoring ProfileChunk for undeclared Profile with id ${event.id || DEFAULT_ID}`,
|
||||
)
|
||||
console.warn(`Ignoring ProfileChunk for undeclared Profile with id ${event.id || pidTid}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user