firefox-devtools / firefox-devtools/profiler

Chrome importer drops frame level line number information

Open
#6,182 3 comments 0 reactions 1 assignee Claimed by @canova View on GitHub
profile data
Dominant language
TypeScript
Stars
1.5k
Forks
491
Avg merge
3d 46m
Merged PRs (30d)
27

Description

When importing Chrome/Node (V8) cpuprofiles, we drop the `positionTicks` data on each node, and add the `callFrame` line column numbers (which is only for `funcTable`) to `frameTable` as well. Because of this, both `funcTable` and `frameTable` line numbers show the function definition only. And because of that the source view and per-line timings only reflect each function's definition line rather than the lines that actually executed.

Looking at the v8 profile it looks like they carry two line sources per node:
- `callFrame.lineNumber` which is where the function is defined.
- `positionTicks: [{line, ticks}, ...]` which is the per-line breakdown of self time, which is what we want for the `frameTable`. See here: https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#type-PositionTickInfo

Here's an example profile: https://share.firefox.dev/4wbNuR6
(Even though we can't see the source code itself) see that all the samples are group together only in the function definition and not split across the function itself at all.

So it would be great to use the `positionTicks` in the `frameTable`, so we can get better and more accurate line timings in the source view.

It looks like they have a `tick` count there, so we need to do something like: create sibling frames for the same func (one per line) and distribute the node's leaf samples across them proportionally to tick counts.

Also this is the place where we add the line and column number to the frame table:
https://github.com/firefox-devtools/profiler/blob/bd2a5cf2d218fc0131a5bd659ec8c7d414dbccf0/src/profile-logic/import/chrome.ts#L646-L657

┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/FP-1364)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.