Skip to content

Expose counter information in profiler-cli#6084

Open
fatadel wants to merge 3 commits into
firefox-devtools:mainfrom
fatadel:issue-6040-1
Open

Expose counter information in profiler-cli#6084
fatadel wants to merge 3 commits into
firefox-devtools:mainfrom
fatadel:issue-6040-1

Conversation

@fatadel

@fatadel fatadel 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 mstange June 4, 2026 12:30
@codecov

codecov Bot 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 (429b2ec).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/profile-query/formatters/counter-info.ts 73.11% 25 Missing ⚠️
src/selectors/profile.ts 14.28% 6 Missing ⚠️
src/profile-query/counter-map.ts 92.30% 1 Missing ⚠️
src/profile-query/formatters/profile-info.ts 85.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

canova commented Jun 4, 2026

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

fatadel commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@canova makes sense, updated.

@canova canova 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 thread src/profile-query/formatters/profile-info.ts Outdated
Comment thread src/profile-query/formatters/profile-info.ts Outdated
Comment thread src/profile-query/types.ts Outdated
Comment thread src/profile-query/formatters/counter-info.ts Outdated
fatadel added 3 commits June 22, 2026 16:40
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 firefox-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

fatadel commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

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 canova June 22, 2026 14:51
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.

Expose counter information in profiler-cli

2 participants