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

@mstange mstange commented Jun 1, 2026

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 canova June 1, 2026 15:25
@mstange mstange self-assigned this Jun 1, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

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 lines Patch % Lines
src/profile-logic/insert-stack-labels.ts 95.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 mstange force-pushed the regular-labels-helper branch from b9f7919 to 53f9bf4 Compare June 1, 2026 20:42
Copy link
Copy Markdown
Member

@canova canova left a comment

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
Contributor Author

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
Contributor Author

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})`;
Copy link
Copy Markdown
Member

@canova canova Jun 2, 2026

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:main Jun 2, 2026
21 checks passed
Sign up for free to 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