joular/joularjx

No "Combined" value in latest version of powermetrics in macOS

adelnoureddine opened this issue · 13 comments

There is no line with "Combined" in latest version of powermetrics in macOS.

In particular, we tested on a MacBook Air (M2, 2022), and the powermetrics command doesn't have the combined line (which is read in JoularJX).

@metacosm, as you wrote the initial PR, could you have a look please?
@olegoaer could help in testing on macOS.

Hmm, that's weird, I have the "Combined Power" line on my M1 Max on 14.1.1.
@olegoarer, could you please send me the output of running sudo powermetrics --samplers cpu_power -i 1000 -n 1 to see how different it is?

hi @metacosm
I just run the command:

Machine model: Mac14,2
OS version: 21G72
Boot arguments: 
Boot time: Mon Oct  2 10:37:21 2023



*** Sampled system activity (Tue Nov 28 11:28:55 2023 +0100) (1002.80ms elapsed) ***


**** Processor usage ****

E-Cluster Power: 6 mW
E-Cluster HW active frequency: 919 MHz
E-Cluster HW active residency:   5.37% (600 MHz:   0% 912 MHz: 100% 1284 MHz:   0% 1752 MHz:   0% 2004 MHz:   0% 2256 MHz:   0% 2424 MHz: .44%)
E-Cluster idle residency:  94.63%
E-Cluster instructions retired: 5.66564e+07
E-Cluster instructions per clock: 0.996462
CPU 0 frequency: 920 MHz
CPU 0 idle residency:  97.09%
CPU 0 active residency:   2.91% (600 MHz:   0% 912 MHz: 2.9% 1284 MHz:   0% 1752 MHz:   0% 2004 MHz:   0% 2256 MHz:   0% 2424 MHz: .02%)
CPU 1 frequency: 922 MHz
CPU 1 idle residency:  98.03%
CPU 1 active residency:   1.97% (600 MHz:   0% 912 MHz: 2.0% 1284 MHz:   0% 1752 MHz:   0% 2004 MHz:   0% 2256 MHz:   0% 2424 MHz: .01%)
CPU 2 frequency: 943 MHz
CPU 2 idle residency:  98.82%
CPU 2 active residency:   1.18% (600 MHz:   0% 912 MHz: 1.2% 1284 MHz:   0% 1752 MHz:   0% 2004 MHz:   0% 2256 MHz:   0% 2424 MHz: .02%)
CPU 3 frequency: 913 MHz
CPU 3 idle residency:  99.04%
CPU 3 active residency:   0.96% (600 MHz:   0% 912 MHz: .96% 1284 MHz:   0% 1752 MHz:   0% 2004 MHz:   0% 2256 MHz:   0% 2424 MHz: .00%)

P-Cluster Power: 4 mW
P-Cluster HW active frequency: 667 MHz
P-Cluster HW active residency:   0.00% (660 MHz: 100% 924 MHz:   0% 1188 MHz:   0% 1452 MHz:   0% 1704 MHz:   0% 1968 MHz:   0% 2208 MHz:   0% 2400 MHz:   0% 2568 MHz:   0% 2724 MHz:   0% 2868 MHz:   0% 2988 MHz:   0% 3096 MHz:   0% 3204 MHz: .03% 3324 MHz: .25% 3408 MHz:   0% 3504 MHz:   0%)
P-Cluster idle residency: 100.00%
P-Cluster instructions retired: 6.11748e+07
P-Cluster instructions per clock: 2.88735
CPU 4 frequency: 3079 MHz
CPU 4 idle residency:  99.81%
CPU 4 active residency:   0.19% (660 MHz: .03% 924 MHz:   0% 1188 MHz:   0% 1452 MHz:   0% 1704 MHz:   0% 1968 MHz:   0% 2208 MHz:   0% 2400 MHz:   0% 2568 MHz:   0% 2724 MHz:   0% 2868 MHz:   0% 2988 MHz:   0% 3096 MHz:   0% 3204 MHz:   0% 3324 MHz: .04% 3408 MHz:   0% 3504 MHz: .12%)
CPU 5 frequency: 1814 MHz
CPU 5 idle residency:  99.99%
CPU 5 active residency:   0.01% (660 MHz: .00% 924 MHz:   0% 1188 MHz:   0% 1452 MHz:   0% 1704 MHz:   0% 1968 MHz:   0% 2208 MHz:   0% 2400 MHz:   0% 2568 MHz:   0% 2724 MHz:   0% 2868 MHz:   0% 2988 MHz:   0% 3096 MHz:   0% 3204 MHz:   0% 3324 MHz: .00% 3408 MHz:   0% 3504 MHz:   0%)
CPU 6 frequency: 660 MHz
CPU 6 idle residency: 100.00%
CPU 6 active residency:   0.00% (660 MHz: .00% 924 MHz:   0% 1188 MHz:   0% 1452 MHz:   0% 1704 MHz:   0% 1968 MHz:   0% 2208 MHz:   0% 2400 MHz:   0% 2568 MHz:   0% 2724 MHz:   0% 2868 MHz:   0% 2988 MHz:   0% 3096 MHz:   0% 3204 MHz:   0% 3324 MHz:   0% 3408 MHz:   0% 3504 MHz:   0%)
CPU 7 frequency: 660 MHz
CPU 7 idle residency: 100.00%
CPU 7 active residency:   0.00% (660 MHz: .00% 924 MHz:   0% 1188 MHz:   0% 1452 MHz:   0% 1704 MHz:   0% 1968 MHz:   0% 2208 MHz:   0% 2400 MHz:   0% 2568 MHz:   0% 2724 MHz:   0% 2868 MHz:   0% 2988 MHz:   0% 3096 MHz:   0% 3204 MHz:   0% 3324 MHz:   0% 3408 MHz:   0% 3504 MHz:   0%)

System instructions retired: 1.17831e+08
System instructions per clock: 1.50979
ANE Power: 0 mW
DRAM Power: 19 mW
DCS Power: 36 mW
CPU Power: 10 mW
GPU Power: 0 mW
Package Power: 25 mW

Interesting that you get such a different output for a processor that should be fairly similar to mine…

For reference, this is what I get:

Machine model: MacBookPro18,4
OS version: 23B81
Boot arguments: 
Boot time: Wed Nov  8 16:44:22 2023



*** Sampled system activity (Tue Nov 28 14:37:01 2023 +0100) (1006.50ms elapsed) ***


**** Processor usage ****

E-Cluster Online: 100%
E-Cluster HW active frequency: 1578 MHz
E-Cluster HW active residency:  68.75% (600 MHz:   0% 972 MHz:  19% 1332 MHz:  24% 1704 MHz:  28% 2064 MHz:  28%)
E-Cluster idle residency:  31.25%
CPU 0 frequency: 1608 MHz
CPU 0 active residency:  55.98% (600 MHz:   0% 972 MHz: 9.6% 1332 MHz:  13% 1704 MHz:  16% 2064 MHz:  18%)
CPU 0 idle residency:  44.02%
CPU 1 frequency: 1590 MHz
CPU 1 active residency:  51.46% (600 MHz:   0% 972 MHz: 9.7% 1332 MHz:  12% 1704 MHz:  14% 2064 MHz:  16%)
CPU 1 idle residency:  48.54%

P0-Cluster Online: 100%
P0-Cluster HW active frequency: 3077 MHz
P0-Cluster HW active residency:  98.60% (600 MHz:   0% 828 MHz:   0% 1056 MHz: .79% 1296 MHz: .03% 1524 MHz:   0% 1752 MHz:   0% 1980 MHz:   0% 2208 MHz:   0% 2448 MHz:   0% 2676 MHz: .03% 2904 MHz: .74% 3036 MHz:  43% 3132 MHz:  51% 3168 MHz: .23% 3228 MHz: 4.6%)
P0-Cluster idle residency:   1.40%
CPU 2 frequency: 3216 MHz
CPU 2 active residency:  93.87% (600 MHz:   0% 828 MHz:   0% 1056 MHz: .41% 1296 MHz: .00% 1524 MHz:   0% 1752 MHz:   0% 1980 MHz:   0% 2208 MHz:   0% 2448 MHz:   0% 2676 MHz:   0% 2904 MHz: .49% 3036 MHz: .11% 3132 MHz:   0% 3168 MHz: 1.0% 3228 MHz:  92%)
CPU 2 idle residency:   6.13%
CPU 3 frequency: 3214 MHz
CPU 3 active residency:  97.05% (600 MHz:   0% 828 MHz:   0% 1056 MHz: .45% 1296 MHz: .03% 1524 MHz:   0% 1752 MHz:   0% 1980 MHz:   0% 2208 MHz:   0% 2448 MHz:   0% 2676 MHz:   0% 2904 MHz: .66% 3036 MHz: .08% 3132 MHz:   0% 3168 MHz: .96% 3228 MHz:  95%)
CPU 3 idle residency:   2.95%
CPU 4 frequency: 3215 MHz
CPU 4 active residency:  41.05% (600 MHz:   0% 828 MHz:   0% 1056 MHz: .17% 1296 MHz: .00% 1524 MHz:   0% 1752 MHz:   0% 1980 MHz:   0% 2208 MHz:   0% 2448 MHz:   0% 2676 MHz:   0% 2904 MHz: .31% 3036 MHz: .00% 3132 MHz:   0% 3168 MHz: .87% 3228 MHz:  40%)
CPU 4 idle residency:  58.95%
CPU 5 frequency: 3213 MHz
CPU 5 active residency:  18.84% (600 MHz:   0% 828 MHz:   0% 1056 MHz: .09% 1296 MHz: .00% 1524 MHz:   0% 1752 MHz:   0% 1980 MHz:   0% 2208 MHz:   0% 2448 MHz:   0% 2676 MHz:   0% 2904 MHz: .21% 3036 MHz: .01% 3132 MHz:   0% 3168 MHz: .40% 3228 MHz:  18%)
CPU 5 idle residency:  81.16%

P1-Cluster Online: 100%
P1-Cluster HW active frequency: 1266 MHz
P1-Cluster HW active residency:   9.59% (600 MHz:  45% 828 MHz: 4.0% 1056 MHz:  14% 1296 MHz: 7.2% 1524 MHz: 6.2% 1752 MHz: 5.1% 1980 MHz: 2.3% 2208 MHz: .97% 2448 MHz: 1.6% 2676 MHz: .79% 2904 MHz: .32% 3036 MHz: .16% 3132 MHz: .42% 3168 MHz: .85% 3228 MHz:  11%)
P1-Cluster idle residency:  90.41%
CPU 6 frequency: 1813 MHz
CPU 6 active residency:   8.17% (600 MHz: .23% 828 MHz: .01% 1056 MHz: 2.1% 1296 MHz: 1.4% 1524 MHz: 1.5% 1752 MHz: .37% 1980 MHz: .29% 2208 MHz: .04% 2448 MHz: .06% 2676 MHz:   0% 2904 MHz: .28% 3036 MHz:   0% 3132 MHz: .03% 3168 MHz: .12% 3228 MHz: 1.7%)
CPU 6 idle residency:  91.83%
CPU 7 frequency: 2196 MHz
CPU 7 active residency:   1.03% (600 MHz: .03% 828 MHz: .00% 1056 MHz: .11% 1296 MHz: .20% 1524 MHz: .08% 1752 MHz: .02% 1980 MHz: .10% 2208 MHz: .00% 2448 MHz: .01% 2676 MHz:   0% 2904 MHz: .18% 3036 MHz:   0% 3132 MHz:   0% 3168 MHz: .00% 3228 MHz: .29%)
CPU 7 idle residency:  98.97%
CPU 8 frequency: 1775 MHz
CPU 8 active residency:   0.58% (600 MHz: .04% 828 MHz: .00% 1056 MHz: .19% 1296 MHz: .07% 1524 MHz: .06% 1752 MHz: .00% 1980 MHz: .05% 2208 MHz:   0% 2448 MHz: .00% 2676 MHz:   0% 2904 MHz: .03% 3036 MHz:   0% 3132 MHz:   0% 3168 MHz: .00% 3228 MHz: .13%)
CPU 8 idle residency:  99.42%
CPU 9 frequency: 2346 MHz
CPU 9 active residency:   1.49% (600 MHz: .01% 828 MHz: .00% 1056 MHz: .10% 1296 MHz: .05% 1524 MHz: .05% 1752 MHz: .52% 1980 MHz: .09% 2208 MHz:   0% 2448 MHz: .00% 2676 MHz:   0% 2904 MHz: .01% 3036 MHz:   0% 3132 MHz:   0% 3168 MHz:   0% 3228 MHz: .66%)
CPU 9 idle residency:  98.51%

CPU Power: 5128 mW
GPU Power: 68 mW
ANE Power: 0 mW
Combined Power (CPU + GPU + ANE): 5195 mW

Indeed. I see that "combined" is just the addition of 3 values.

Could you add the output of powermetrics -h as well, please?

powermetrics -h

Usage: powermetrics [-i sample_interval] [-r order] [-t wakeup_cost]

  Gather and display CPU usage statistics (divided into time spent in
  user mode and supervisor mode), timer and interrupt wakeup frequency
  (total and, for near-idle workloads, those that resulted in package
  C-state exits), and on supported platforms, interrupt frequencies
  (categorized by CPU number), package C-state statistics (an indication
  of the time the core complex + integrated graphics, if any, were in
  low-power idle states), as well as the average execution frequency for
  each CPU when not idle.

The following command-line options are supported:

    -h | --help                  show this message

    -A | --show-all              Enables all samplers and displays all the
                                 available information for each sampler.

    -a | --poweravg <N>          display poweravg every N samples (0=disabled) [default: 10]
    -b | --buffer-size <size>    set output buffer size (0=none, 1=line)
    -f | --format <format>       display data in specified format [default: text]
    -i | --sample-rate <N>       sample every N ms (0=disabled) [default: 5000ms]
    -n | --sample-count <N>      obtain N periodic samples (-1=infinite) [default: -1]
    -o | --output-file <file>    output to file [default: stdout]
    -r | --order <method>        order process list using specified method [default: composite]
    -s | --samplers <samplers>   comma separated list of samplers and sampler groups
    -t | --wakeup-cost <N>       assume package idle wakeups have a CPU time
                                 cost of N us when using hybrid sort orders
                                 using idle wakeups with time-based metrics


    --show-initial-usage         print initial sample for entire uptime
    --show-usage-summary         print final usage summary when exiting

    --show-extra-power-info      unsupported power info (may change between releases)

    --show-pstates               show pstate distribution (XCPM only)
    --show-plimits               cpu limiting information
    --show-cpu-qos               show per cpu QOS breakdowns
    --show-cpu-scalability       show per cpu workload scalability
    --show-hwp-capability        show per cpu-thread HWP estimated efficient and guarateed frequencies (instantaneous)
    --show-process-coalition     group processes by coalitions and show per coalition information
    --show-process-wait-times    show per-process sfi wait time info
    --show-process-qos-tiers     show per-process QOS latency and throughput tiers
    --show-process-io            show per-process io information
    --show-process-gpu           show per-process gpu time
    --show-process-netstats      show per-process network information
    --show-process-qos           show QOS times aggregated by process
    --show-process-amp           show per-process AMP information
    --show-process-energy        show per-process energy impact number
                                 This implicitly enables sampling of all the
                                 above per-process statistics.
    --show-process-samp-norm     Show CPU time normailzed by the sample window.
    --handle-invalid-values      powermetrics will output invalid=true rather
                                 than abort when it sees invalid values.
    --hide-cpu-duty-cycle        hide CPU duty cycle data
    --unhide-info <samplers>     comma separated list of samplers to unhide (backwards compatibility)

The following sort orders are supported by --order:

    pid         process identifier
    wakeups     total package idle wakeups         (alias: -W)
    cputime     total CPU time used                (alias: -C)
    composite   weighted hybrid of package idle
                wakeups and CPU time used          (alias: -O)

The following output formats are supported by --format:

    text        human-readable text output
    plist       machine-readable property list, NUL-separated

This tool also implements special behavior upon receipt of certain signals
to aid with the automated collection of data:

    SIGINFO                 take an immediate sample
    SIGIO                   flush any buffered output
    SIGINT/SIGTERM/SIGHUP   stop sampling and exit

The following samplers are supported by --samplers:

    tasks             per task cpu usage and wakeup stats
    battery           battery and backlight info
    network           network usage info
    disk              disk usage info
    int_sources       interrupt sources information
    interrupts        interrupt distribution
    cpu_power         cpu power and frequency info
    thermal           thermal pressure notifications
    sfi               selective forced idle information
    gpu_power         gpu power and frequency info
    bandwidth         amc bandwidth counters
    ane_power         ane power and frequency info

and the following sampler groups are supported by --samplers:

    all           tasks,battery,network,disk,int_sources,interrupts,cpu_power,thermal,sfi,gpu_power,bandwidth,ane_power
    default       tasks,battery,network,disk,interrupts,cpu_power,gpu_power,ane_power

🤔 OK, most of the information is the same but you have more available samplers than I do: I don't have int_sources or bandwidth. I was hoping to see what the DCS power refers to and how they define Package… maybe in the man page but this won't fit here and I'm not sure if there's a way to find all the different versions of the man page online.

DCS seems to be related to DRAM : DCS = DRAM Command Scheduler (source here and here).

Note also that the output is not the latest powermetrics version as the OS version reported by @olegoaer is actually pretty old.

Thanks for the PR.

@olegoaer, could you check if you can update powemetrics in macOS?

@metacosm Do we know which minimum version we need to have the combined line?

No idea, there isn't much documentation on powermetrics, unfortunately. The PR should handle both versions adequately now at the expense of a little more processing. If we could find reference documentation, we could base the parsing of the output on the OS version that's mentioned at the top but so far, I haven't been able to find authoritative information on the topic, notably because the output most likely also depend on the CPU type (Intel vs. Apple Silicon) as well.

FYI, I updated my OS to the latest version (OS version: 23B92) and the Combined Power value is now there.

FYI, I updated my OS to the latest version (OS version: 23B92) and the Combined Power value is now there.

Thanks. It's good to know that recent (and I assume future) versions have the combined value.