Skip to content

Add an insertStackLabels helper. - #6076

Merged
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:regular-labels-helper
Jun 2, 2026
Merged

Add an insertStackLabels helper.#6076
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:regular-labels-helper

Conversation

@mstange

Copy link
Copy Markdown
Contributor

This takes an existing profile and creates label frames based on function name prefix matching. The label frames are inserted as parent stack nodes of the matched stack node.

This lets us turn native profiles from e.g. samply into profiles where the JS-only view shows DOM calls.

@mstange
mstange requested a review from canovaJune 1, 2026 15:25
@mstangemstange self-assigned this Jun 1, 2026
@codecov

codecovBot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.82%. Comparing base (53f9bf4) to head (a99497b).
⚠️ Report is 3 commits behind head on main.

Files with missing linesPatch %Lines
src/profile-logic/insert-stack-labels.ts95.45%5 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #6076 +/- ##
=======================================
Coverage 83.82% 83.82% =======================================
Files 330 330 Lines 34680 34682 +2 Branches 9608 9703 +95 =======================================
+ Hits 29070 29072 +2 
Misses 5181 5181 Partials 429 429 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This takes an existing profile and creates label frames based
on function name prefix matching. The label frames are inserted
as parent stack nodes of the matched stack node.
This lets us turn native profiles from e.g. samply into profiles
where the JS-only view shows DOM calls.
@mstange
mstangeforce-pushed the regular-labels-helper branch from b9f7919 to 53f9bf4CompareJune 1, 2026 20:42

@canovacanova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

const funcTable = shallowCloneFuncTable(oldFuncTable);
const stringTable = StringTable.withBackingArray(stringArray);

const rootLabelName = 'Root (unaccounted / catch-all)';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does unaccounted mean here? Anything other than the provided label frames?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I really wasn't sure what to call this. Unaccounted here means that, if you look at the JS-only call tree in inverted mode, the self samples of this label are any samples that aren't covered by the provided label frames (or JS functions).

} = profile.shared;
const frameTable = shallowCloneFrameTable(oldFrameTable);
const funcTable = shallowCloneFuncTable(oldFuncTable);
const stringTable = StringTable.withBackingArray(stringArray);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shallow copy frame and func table but not the string array. Should we slice to keep this stringArray immutable?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I'd say mutating the stringArray by appending is fine - having unused strings in it doesn't really impact anything.

const sourceIndex = funcTable.source[funcIndex];
if (sourceIndex !== null) {
const filenameString = stringArray[sources.filename[sourceIndex]];
nameString += ` (${filenameString})`;

@canovacanovaJun 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see what you mean now. It looks a bit wasteful to compute this for every func, but it's also probably fine for the node script.

I was actually thinking about doing this the other way around. Pre-processing the funcPrefixes array to split the name and file path, so they can be checked individually. But I didn't check the second PR that uses this yet, I don't know how feasible that is. I don't mind either way.

@mstange
mstange enabled auto-merge June 2, 2026 17:02
@mstange
mstange merged commit a2f2f13 into firefox-devtools:mainJun 2, 2026
21 checks passed
mstange added a commit that referenced this pull request Jun 4, 2026
Based on #6076.
This lets us create profiles like https://share.firefox.dev/4mPPTgr with
DOM label frames that show up in the JS-only view, for profiles from
samply, based on function name matching. The matchers are declared in a
toml file that is passed to the script.
Example TOML file:
https://gist.github.com/mstange/827c40404c987bc566b8b324efc0a04f
@canovacanova mentioned this pull request Jun 16, 2026
canova added a commit that referenced this pull request Jun 16, 2026
Changes:
[Nazım Can Altınova] Fix call node context menu being hidden behind
source view bottom box (#6045)
[Nazım Can Altınova] Pass `--use-env-proxy` only when the node version
is >= 24 (#6064)
[fatadel] Upgrade @firefox-devtools/react-contextmenu to 5.2.4 (#6066)
[Markus Stange] Switch profiler-edit from minimist to commander (#6065)
[Markus Stange] Support reading profiles from JsonSlabs files (#6037)
[Florian Quèze] Don't fail profile processing when a marker's stack
field is not a backtrace (#6069)
[fatadel] Replace the footer-links overlay with a settings menu (#6042)
[fatadel] Upgrade @types/node to match Node 24 (#6070)
[fatadel] Remove unused undici-types package (#6074)
[cathaysia] Update isLocalURL to include LAN addresses, .local domains,
and hostn… (#5973)
[Markus Stange] Fix from-url with binary profiles (#6072)
[fatadel] Upgrade to React 19 (#6067)
[Markus Stange] Add an insertStackLabels helper. (#6076)
[fatadel] Drive counter tooltips from a tooltipRows schema (#6023)
[fatadel] Add TrackPower--tooltip-average-power-microwatt (#6080)
[Markus Stange] Downgrade to React 19.1 to fix unusable dev build
performance. (#6082)
[Nazım Can Altınova] Add source map symbolication and source view
support (#6018)
[spokodev] fix(FilterNavigatorBar): clip overflow so many breadcrumbs do
not expand the parent (#6085)
[Markus Stange] Move paddings inside the tree header cells. (#6002)
[Markus Stange] Add an --insert-label-frames argument to the
profiler-edit tool (#5966)
[Markus Stange] Stop printing "error: too many arguments" during tests.
(#6088)
[Markus Stange] More additions to profiler-edit, for sp3 profiles
(#6009)
[Nazım Can Altınova] Do not rely on localized texts in the settings menu
tests (#6101)
And special thanks to our localizers:
be: Andrei Mukamolau
de: Ger
de: Michael Köhler
de: Ralf Duehnfahr
el: Jim Spentzos
en-CA: chutten
en-GB: Ian Neal
es-CL: ravmn
fr: Théo Chevalier
fr: wy
fur: Fabio Tomat
fy-NL: Fjoerfoks
ia: Melo46
it: Francesco Lodolo [:flod]
nl: Mark Heijl
ru: Valery Ledovskoy
sr: Марко Костић (Marko Kostić)
sv-SE: Andreas Pettersson
tr: Grk
tr: Selim Şumlu
zh-CN: Olvcpr423
zh-TW: Pin-guang Chen
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@mstange@canova