mactop
mactop copied to clipboard
Mactop vs. Activity Monitor CPU use totally different, M2 Macbook Air
Mactop always shows ~50% P and E, even when the machine is otherwise idle. Here is what mactop and activity monitor show at the same time, note the P cores seem to be idle in AM and 50% active in mactop, the E cores are more active in AM but still not 50%:
I've tried htop, gotop, zenith and some others and they all largely agree with AM, only mactop shows this 50% CPU use...
Sorry for the late reply, please post your powermetrics output here if you can, that would assist in debugging this issue as we parse stats from it depending on the chip. It is possibly related to the other open issue: https://github.com/context-labs/mactop/issues/26
sudo powermetrics -i 1000 -n 20 -o pm.log
After running this log, I immediately started mactop without anything else running and this is what it shows:
Yea, so it looks like there is no bug here, your machines E-Cluster and P-Cluster (E and P Cores) are in fact running at those percentages correctly, (cherry picking a few of what we parse out of your pm.log here):
E-Cluster HW active residency: 55.86%
P-Cluster HW active residency: 50.12%
E-Cluster HW active residency: 54.01%
P-Cluster HW active residency: 50.22%
E-Cluster HW active residency: 54.53%
P-Cluster HW active residency: 50.27%
I recommend checking what processes you have running, seems kernel_task, com.apple.DriverKit.AppleUserECM, and WindowServer are the top three besides powermetrics utilizing a good chunk of CPU
Activity monitor shows no activity in the p-cluster at all, and it seems the cluster vs individual stats do not line up::
P-Cluster idle residency: 49.92%
CPU 4 idle residency: 99.33%
CPU 5 idle residency: 99.90%
CPU 6 idle residency: 99.96%
CPU 7 idle residency: 100.00%
How can each CPU's idle be >99% but the overall cluster is only 50% idle? Activity monitor seems to be using the CPU stats (last 4 columns are P cores I think):
But from your perspective, this is a powermetrics problem by the looks of it...
EDIT: an average of the CPU core values would work in my case...
Activity monitor shows no activity in the p-cluster at all, and it seems the cluster vs individual stats do not line up::
P-Cluster idle residency: 49.92% CPU 4 idle residency: 99.33% CPU 5 idle residency: 99.90% CPU 6 idle residency: 99.96% CPU 7 idle residency: 100.00%How can each CPU's idle be >99% but the overall cluster is only 50% idle? Activity monitor seems to be using the CPU stats (last 4 columns are P cores I think):
![]()
We use HW active residency and yes possibly a powermetrics issue (Apple)
Right, powermetrics is misleading on either active or idle residency on my M2, here the active residence is 55.3% but the active residency of the CPUs is 13.1% 7.1% 4.4% & 2.9%, even if you sum them they don't make 55.3%!?!?
E-Cluster HW active frequency: 936 MHz
E-Cluster HW active residency: 55.31% (600 MHz: 0% 912 MHz: 54% 1284 MHz: .09% 1752 MHz: 1.2% 2004 MHz: .11% 2256 MHz: .11% 2424 MHz: .04%)
E-Cluster idle residency: 44.69%
CPU 0 frequency: 1036 MHz
CPU 0 active residency: 13.10% (600 MHz: 0% 912 MHz: 11% 1284 MHz: .01% 1752 MHz: 1.3% 2004 MHz: .19% 2256 MHz: .19% 2424 MHz: .04%)
CPU 0 idle residency: 86.90%
CPU 1 frequency: 982 MHz
CPU 1 active residency: 7.13% (600 MHz: 0% 912 MHz: 6.6% 1284 MHz: .01% 1752 MHz: .48% 2004 MHz: .03% 2256 MHz: .02% 2424 MHz: .03%)
CPU 1 idle residency: 92.87%
CPU 2 frequency: 949 MHz
CPU 2 active residency: 4.39% (600 MHz: 0% 912 MHz: 4.2% 1284 MHz: .00% 1752 MHz: .10% 2004 MHz: .01% 2256 MHz: .01% 2424 MHz: .04%)
CPU 2 idle residency: 95.61%
CPU 3 frequency: 1055 MHz
CPU 3 active residency: 2.87% (600 MHz: 0% 912 MHz: 2.4% 1284 MHz: .00% 1752 MHz: .44% 2004 MHz: .00% 2256 MHz: .01% 2424 MHz: .02%)
CPU 3 idle residency: 97.13%
The CPU stats seem more reliable than the cluster ones, and they also align more closely to the low power draw and activity monitor / htop etc.
Should I close this (or leave it if others hit the same issue as me)?
Just a user since yesterday, but I also noticed #26. My guess is that the percentage should be corrected for the current frequency. My M1 Max has a max frequency of 3200 MHz. When I do an Xcode build it goes to almost 100% on 3180MHz and there is no overflow. I see overflows a lot when frequency is (a lot) lower.
Just resolved this in v0.2.0, will close this once I get a few confirmations.
I still see the same problems with V0.2 on my M2, comparing zenith and mactop side-by-side zenith shows only 2 P cores active sum ~10% and mactop shows ~52%:
zenith reports what Apple's activity monitor and htop etc. uses. Powermetrics still shows big differences between the individual CPU active residency (which is closer to activity monitor/zenith/htop) and the Cluster active residency:
P-Cluster HW active frequency: 694 MHz (max: 3504 Mhz)
P-Cluster HW active residency: 51.33%
CPU 4 active residency: 4.58%
CPU 5 active residency: 2.22%
CPU 6 active residency: 1.64%
CPU 7 active residency: 1.38%
Note if I multiply cluster active residency by (active frequency ÷ max frequency), then the active residency is similar to the sum of the CPU active residencies:
Thank you @iandol for the info, I am thinking we will move away from using powermetrics soon in coming updates, at least for CPU E/P Core calculations, we should now at least match asitop in terms of parsing and handling powermetrics data. I will more than likely start work on the new native methods soon to probably just use macOS API directly with cgo or something.
https://github.com/context-labs/mactop/pull/37
I encourage those interested to test out the development branch as it now uses Apple's native mach kernel api for CPU information! It should now match up very closely now to other monitoring applications!
Interesting and relevant article: https://eclecticlight.co/2024/11/08/why-cpu-in-activity-monitor-isnt-what-you-think/
Closing this now, since CPU usage was entirely revamped and now using Apple's native mach kernel API, you may see slight differences between other monitors but it is a matter of when the delta counting starts for the mach kernel calculation, but should be very very close to any others now. Hitting "l" will bring up the more advanced individual core measurements now. Thank you for all the testing you have done iandol!