Skip to content

Expose counter information in profiler-cli - #6084

Merged
fatadel merged 4 commits into
firefox-devtools:mainfrom
fatadel:issue-6040-1
Jun 23, 2026
Merged

Expose counter information in profiler-cli#6084
fatadel merged 4 commits into
firefox-devtools:mainfrom
fatadel:issue-6040-1

Conversation

@fatadel

@fatadelfatadel commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Add counter list and counter info <handle> commands, and list each counter under its process in profile info, to inspect any counter track from the terminal. Counters get stable c-N handles, like threads and functions.

Per-counter stats come from the counter's own tooltip schema, reusing the timeline tooltips' labels and formatters so the CLI and UI agree. Stats respect the current zoom.

Closes#6040.


Usage examples

➜ profiler git:(issue-6040-1) pq counter list
[Thread: t-7 (GeckoMain) | View: Full profile | Full: 3.449s]
Counters (22):
c-0: Bandwidth (Bandwidth) - Data transferred in the visible range: 182KB (0.020 g CO₂e) [67 samples]
c-1: Process CPU (CPU) [345 samples]
...
➜ profiler git:(issue-6040-1) pq counter info c-1
[Thread: t-7 (GeckoMain) | View: Full profile | Full: 3.449s]
Counter c-1: Process CPU
Name: processCPU
Category: CPU
Description: Process CPU utilization
Unit: percent
Graph type: line-rate
Main thread: t-0 (GeckoMain)
Samples: 345 total, 345 in current range
Time span: 2h9m → 2h9m
[Thread: t-7 (GeckoMain) | View: Full profile | Full: 3.449s]
Name: Firefox 150 – macOS 26.5.0
Platform: macOS 26.5.0
This profile contains 8 threads across 7 processes.
Top processes and threads by CPU usage:
p-0: Parent Process [pid 1999] [ts<12W → end] - 297.869ms
t-0: GeckoMain [tid 16337] - 297.869ms
c-0: Bandwidth - Data transferred in the visible range: 182KB (0.020 g CO₂e) [67 samples]
c-1: Process CPU [345 samples]
c-2: Memory - memory range in graph: 13.7MB [322 samples]
c-3: Process Power - Energy used in the visible range: 185 µWh (0.088 mg CO₂e) [345 samples]
...
CPU activity over time:
- 22% for 769.4ms: [ts-1 → ts-z] (14.371ms - 3.438s)
- 60% for 62.0ms: [ts-1 → ts-3] (14.371ms - 117.22ms)
...

@fatadel
fatadel requested review from canova and mstangeJune 4, 2026 12:30
@codecov

codecovBot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.01575% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.46%. Comparing base (53a3071) to head (559666a).
⚠️ Report is 1 commits behind head on main.

Files with missing linesPatch %Lines
src/profile-query/formatters/counter-info.ts73.11%25 Missing ⚠️
src/selectors/profile.ts14.28%6 Missing ⚠️
src/profile-query/counter-map.ts92.30%1 Missing ⚠️
src/profile-query/formatters/profile-info.ts85.71%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #6084 +/- ##
==========================================
+ Coverage 83.35% 83.46% +0.11% 
==========================================
Files 339 341 +2 Lines 35941 36065 +124 Branches 10058 9999 -59 ==========================================
+ Hits 29957 30101 +144 + Misses 5556 5536 -20 
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.

@canova

Copy link
Copy Markdown
Member

pq profile info --counters: I don't think we should have --counters, we should directly put the counters into the list. Similar to how we have a track list in the profiler UI.

@fatadel

Copy link
Copy Markdown
ContributorAuthor

@canova makes sense, updated.

@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 for the PR! Looks great to me with some nits!

One thing I noticed is that I think we don't currently use the sortWeight in the pq profile info command. It would be good to use that so it matches the web frontend. It can be also done as a follow-up.

This is only the first iteration for #6040.

Currently we show the counters in the profile info and get info of them with pq counter info. I think it would be great to get more information of the counter values, similar to "CPU activity over time" section that we have in the pq profile info as a follow-up. What do you think?

Comment threadsrc/profile-query/formatters/profile-info.ts Outdated
Comment threadsrc/profile-query/formatters/profile-info.ts Outdated
Comment threadsrc/profile-query/types.ts Outdated
Comment threadsrc/profile-query/formatters/counter-info.ts Outdated
Add `counter list` and `counter info <handle>` commands, and list each
counter under its process in `profile info`, to inspect any counter
track from the terminal. Counters get stable `c-N` handles, like threads
and functions.
Per-counter stats come from the counter's own tooltip schema, reusing
the timeline tooltips' labels and formatters so the CLI and UI agree.
Stats respect the current zoom.
Closesfirefox-devtools#6040
- Group counters under their process by counter.pid, as the timeline does.
- Add a getCommittedRangeCounterSampleSum selector and use it for the total.
- Drop the unused labelKey from counter stats; the CLI has no localization.
- Cover counter nesting with profile-query unit tests instead of an old fixture.
Both `counter list` and the counters nested in `profile info` follow the
timeline's track order (sortWeight, then name) instead of profile order.
@fatadel

Copy link
Copy Markdown
ContributorAuthor

Thanks for the PR! Looks great to me with some nits!

One thing I noticed is that I think we don't currently use the sortWeight in the pq profile info command. It would be good to use that so it matches the web frontend. It can be also done as a follow-up.

This is only the first iteration for #6040.

Currently we show the counters in the profile info and get info of them with pq counter info. I think it would be great to get more information of the counter values, similar to "CPU activity over time" section that we have in the pq profile info as a follow-up. What do you think?

Thanks for your review! Agree, I've created #6112 as the follow-up. The proper sorting is already there. Actually, there will only be one follow-up for this issue and the current PR fully closes #6040.

@canova, even though you've already approved this PR, could you please have another quick look? Specifically, at the last two commits. I am re-requesting review because the changes are a bit bigger than "non-significant".

@fatadel
fatadel requested a review from canovaJune 22, 2026 14:51

@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 the new changes look good. But now that I spent some more time thinking about the tests, I think we can improve them further. What do you think?

Comment threadprofiler-cli/src/test/integration/counter.test.ts Outdated
- Drop the fixture-based counter integration tests.
- Cover the querier logic in profile-query unit tests with in-memory builders.
- Cover the text formatters in a fixture-free CLI unit test.
@fatadel
fatadel requested a review from canovaJune 23, 2026 09:04

@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!

@fatadel
fatadel merged commit b09232e into firefox-devtools:mainJun 23, 2026
22 of 23 checks passed
@fatadel
fatadel deleted the issue-6040-1 branch June 23, 2026 11:03
@canovacanova mentioned this pull request Jun 29, 2026
canova added a commit that referenced this pull request Jun 29, 2026
Changes:
[Nazım Can Altınova] Bump profiler-cli version to 0.3.0 (#6104)
[Markus Stange] First typed array: Allow profile.shared.stackTable.frame
to be an Int32Array (#6087)
[Nazım Can Altınova] Show more user friendly errors for unsupported
profile version in both the frontend and the cli (#6107)
[fatadel] Expose counter information in profiler-cli (#6084)
[Markus Stange] Split getSelfAndTotal. (#6113)
[Markus Stange] Add missing transform shortcut key handling for S
(focus-self) (#6117)
[Markus Stange] Remove unused isInverted prop from FlameGraphCanvas.
(#6116)
[Markus Stange] Change sidebar splitter CSS to only apply to the
sidebar, not to all splitters under .DetailsContainer (#6114)
[Markus Stange] Pass callNodeInfo to handleCallNodeTransformShortcut.
(#6115)
[Markus Stange] Move column declarations out into a separate file
(#6119)
[fatadel] Keep menu panels above the selected-marker tooltip (#6125)
[Nazım Can Altınova] Make sure to always sanitize source contents even
when no PII sanitization is requested (#6127)
[Markus Stange] Compute FlameGraphTiming rows lazily (#6126)
[Markus Stange] Create a non-connected FlameGraph component (#6118)
[Nazım Can Altınova] 🔃 Sync: l10n -> main (June 29, 2026) (#6130)
And special thanks to our localizers:
de: Michael Köhler
el: Jim Spentzos
en-GB: Ian Neal
es-CL: ravmn
fr: Théo Chevalier
fur: Fabio Tomat
fy-NL: Fjoerfoks
ia: Melo46
it: Francesco Lodolo [:flod]
nl: Mark Heijl
ru: Valery Ledovskoy
sv-SE: Luna Jernberg
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.

Expose counter information in profiler-cli

2 participants

@fatadel@canova