Skip to content

Expose counter information in profiler-cli#6084

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

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

Conversation

@fatadel
Copy link
Copy Markdown
Contributor

@fatadel fatadel commented Jun 4, 2026

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.

This is only the first iteration for #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
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 0.86207% with 115 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.43%. Comparing base (a99497b) to head (ec80263).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
src/profile-query/formatters/counter-info.ts 1.12% 88 Missing ⚠️
src/profile-query/counter-map.ts 0.00% 13 Missing ⚠️
src/profile-query/formatters/profile-info.ts 0.00% 7 Missing ⚠️
src/profile-query/index.ts 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6084      +/-   ##
==========================================
- Coverage   83.82%   83.43%   -0.39%     
==========================================
  Files         330      339       +9     
  Lines       34682    35690    +1008     
  Branches     9703    10017     +314     
==========================================
+ Hits        29072    29779     +707     
- Misses       5181     5483     +302     
+ Partials      429      428       -1     

☔ 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

canova commented Jun 4, 2026

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.

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.

Part of firefox-devtools#6040
@fatadel
Copy link
Copy Markdown
Contributor Author

fatadel commented Jun 4, 2026

@canova makes sense, updated.

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