context-labs/mactop

P-Core usage bar overflow on M1 Pro

laclouis5 opened this issue ยท 19 comments

I'm running mactop v0.1.8 on a M1 Pro MacBook Pro and the P-Core Usage bar randomly spikes and overflows to the right of the terminal and the displayed percentage is absurdly hight (above 2000 %) and does not match with any real workload spike on the system (the system is at rest). During those spikes other tools such as top, Activity Monitor or Mx Power Gadget all show a flat and low P-Core usage and frequency.

Screenshot 2024-05-31 at 18 57 09

Fix is up here #25 will be merged in for v0.1.9, if you can run the PR locally to confirm it resolves the issue for you, thanks.

I cloned and switched to the development branch and then compiled the program following the instructions but the issue is stil present when launching the program with sudo ./mactop. I uninstalled mactop from brew to be sure to launch the right program. The issue seems to spike less often though.

Okay, interesting, can you please post some of your output from powermetrics here, this would also help to assist to see if powermetrics is reporting correctly or if my side of the code. Thank you for debugging ๐Ÿ˜ƒ

Here is some powermetrics logs during approximately 10 seconds with a sample rate of 1 second. mactop overflowed during that period of time. Thank you for the quick answer and support!

powermetrics.log

A weird thing I noticed is that sometimes powermetrics prints this warning/error in between some samples (on stderr apparently): Second underflow occurred..

I second this issue, I encountered the same problem (freshly downloaded from brew)
I have a M1 PRO chip and 32G RAM

I have a M1 Pro with 16 GB ram and encountered the same issue.
I dont know why but it seems like this issue doenst happen when mactop is run in tmux session.
FYI, I installed mactop with homebrew.

Same problem here! M1 Pro (base model 2E 6P)

This isn't fixed, M2 Pro here with v0.1.9 including the #25 patch

Bildschirmfoto 2024-10-29 um 08 53 44

This isn't fixed, M2 Pro here with v0.1.9 including the #25 patch

Bildschirmfoto 2024-10-29 um 08 53 44

Apologies for the late reply, please try to manually build the development branch (v0.2.0) I am working on doing a manual workaround for calculating certain M series chips P and E core usage, due to Apple's powermetrics having a bug/issue, if you are having the issue above, please post your powermetrics output in a text file, as it can help me validate calculations.

Just resolved this in v0.2.0, will close this once I get a few confirmations.

The values reported in mactop match those in powermetrics, but they seem far too high. Even when idle, both P-cores and E-cores are consistently at 50โ€“70%.

In contrast, the values shown in Activity Monitor and iStat Menus are much lower, around 3โ€“4%.

edit: tested with v0.2.1 but still the same

Thanks for testing, yea, the next set of updates we are moving to the direct macOS API via cgo to get individual E and P Core usage values along with total usage percent. Powermetrics seems just buggy and inconsistent across devices, moving to this new way soon will make us more inline with Activity Monitor, htop, etc.

May I ask which API? This sounds great.

May I ask which API? This sounds great.

The host_processor_info within the Mach kernel API accessed with cgo, which is the same as htop and similar to what Activity Monitor and others utilize, I will put the implementation up into the development branch later tonight ๐Ÿ˜Ž

Preview image (WIP)

image

Fantastic!

#37 it is up in the development branch if you wish to test it out! ๐Ÿ‘ ๐Ÿป

CPU usage was revamped and is now using Apple's native mach kernel API as of v0.2.2 of mactop, Closing this. Please update!

@metaspartan
Thanks a lot!!