Skip to content

Add an --insert-label-frames argument to the profiler-edit tool#5966

Merged
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-tppxoqrqsyyy
Jun 4, 2026
Merged

Add an --insert-label-frames argument to the profiler-edit tool#5966
mstange merged 2 commits into
firefox-devtools:mainfrom
mstange:push-tppxoqrqsyyy

Conversation

@mstange
Copy link
Copy Markdown
Contributor

@mstange mstange commented Apr 23, 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

@mstange mstange force-pushed the push-tppxoqrqsyyy branch from c303031 to 39b7942 Compare May 28, 2026 18:30
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 80.67227% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.69%. Comparing base (2fd6ce9) to head (2cb282f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/node-tools/profiler-edit.ts 21.42% 22 Missing ⚠️
src/utils/label-templates.ts 98.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5966      +/-   ##
==========================================
- Coverage   83.70%   83.69%   -0.02%     
==========================================
  Files         337      338       +1     
  Lines       35575    35693     +118     
  Branches     9971     9904      -67     
==========================================
+ Hits        29778    29873      +95     
- Misses       5369     5392      +23     
  Partials      428      428              

☔ View full report in Codecov by Harness.
📢 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.

@mstange mstange force-pushed the push-tppxoqrqsyyy branch 2 times, most recently from 83cd29e to 7354e3c Compare May 30, 2026 00:39
@mstange mstange changed the title Add an --insert-stack-labels modification to the profiler-edit tool Add an --insert-label-frames modification to the profiler-edit tool Jun 1, 2026
@mstange mstange force-pushed the push-tppxoqrqsyyy branch 2 times, most recently from 55816ce to 952d57e Compare June 1, 2026 20:42
@mstange mstange marked this pull request as ready for review June 1, 2026 20:43
@mstange mstange requested review from canova and fatadel as code owners June 1, 2026 20:43
@mstange mstange removed the request for review from fatadel June 1, 2026 20:43
@mstange mstange changed the title Add an --insert-label-frames modification to the profiler-edit tool Add an --insert-label-frames argument to the profiler-edit tool Jun 1, 2026
@mstange mstange force-pushed the push-tppxoqrqsyyy branch 4 times, most recently from 057b358 to 560ba64 Compare June 4, 2026 15:13
Comment thread src/node-tools/profiler-edit.ts Outdated
Comment on lines +109 to +114
if (line !== null && col !== null) {
name += ` (${filename}:${line}:${col})`;
} else if (line !== null) {
name += ` (${filename}:${line})`;
} else {
name += ` (${filename})`;
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.

The comment above mentions that it mirrors getLabelIndexForFunc, but it doesn't seem like it matches fully.

getLabelIndexForFunc constructs it like (${filename}), but this one does it like (${filename}:${line}:${col}).

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.

Oh yes, good catch.

Comment thread src/node-tools/profiler-edit.ts Outdated
autoLabels: AutoLabel[];
};

import { parse as parseToml } from 'smol-toml';
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.

nit: can we move this to the top of the file?

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.

Done.

@mstange mstange force-pushed the push-tppxoqrqsyyy branch from 560ba64 to 9563cd2 Compare June 4, 2026 17:13
mstange added 2 commits June 4, 2026 13:14
In the past we had a hardcoded list of DOM methods in the label matchers.

This modification lets us replace 100 explicit labels of this type:

```
[[labels]]
name = "Document.querySelector"
funcPrefixes = [
  "mozilla::dom::Document_Binding::querySelector(",
  "blink::`anonymous namespace'::v8_document::QuerySelectorOperation",
  "blink::(anonymous namespace)::v8_document::QuerySelectorOperation",
  "WebCore::jsDocumentPrototypeFunction_querySelector",
]
```

with one auto label of this type:

```
[[auto_labels]]
nameTemplate = "{Class}.{method}"
funcPrefixTemplates = [
  "mozilla::dom::{Class}_Binding::{method}(",
  "blink::`anonymous namespace'::v8_{Class:blink_snake}::{method:pascal}Operation",
  "blink::(anonymous namespace)::v8_{Class:blink_snake}::{method:pascal}Operation",
  "WebCore::js{Class}PrototypeFunction_{method}",
]
```

fixup auto labels
This command takes a .toml file and adds label frames to a profile based on 
matching function names.

We want to use this for profiles from samply, to insert labels for DOM calls 
and Layout / Style / etc.

Example:
Before: https://share.firefox.dev/48wEADM
After: https://share.firefox.dev/3P9d3BQ

The toml file has to be provided by the user, because the matched function
names are specific to the program being profiled.

Here's an example toml file:
https://gist.github.com/mstange/827c40404c987bc566b8b324efc0a04f
@mstange mstange force-pushed the push-tppxoqrqsyyy branch from 9563cd2 to 2cb282f Compare June 4, 2026 17:14
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.

Looks good to me!

@mstange mstange merged commit fdb0dce into firefox-devtools:main Jun 4, 2026
21 of 23 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