asitop icon indicating copy to clipboard operation
asitop copied to clipboard

Fix for M3 Max - Using average of cores instead of relying on cluster idle ratio

Open gavi opened this issue 1 year ago • 15 comments

Seems like the idle ratio of Cluster is reporting as zero in powermetrics which might be causing the CPU gauges to show 100%. This code fix simply averages the individual core idle ratios.

gavi avatar Dec 29 '23 15:12 gavi

Before fix on M3 Max (40 core GPU)

image

After fix

image

gavi avatar Dec 29 '23 15:12 gavi

please @tlkh merge this one 🙏

ivanfioravanti avatar Dec 29 '23 21:12 ivanfioravanti

@gavi Thank you so much! Your fix worked for me.

samarthm314 avatar Dec 30 '23 15:12 samarthm314

I tried the patch. It helped a little bit but seems wrong still. I am using M3 Max 16C/40GPU with just chrome browser running to test.

M3 max 16c/40gpu still showing 90% usage on e-Cores and 42-100% usage on P-cores.

Comparing this to

istatmenu (4 cpus - probably E-cores pegged near 90%, and 12 other CPU (I assume P-cores) showing nothing 1% here and there. Activity monitor is matching the istatsmenu

At least it's no longer pegging both e-cores and p-cores at 100% but something is still wrong.

I wonder how the youtubers are checking the stats these days with asitop. :) Screenshot 2024-01-09 at 4 18 06 PM

chiltalk avatar Jan 09 '24 21:01 chiltalk

I am not sure what to trust though. If you look at the plist file that is generated by powermetrics , the p-cores were showing usage but like you said iStats and the activity monitor were not. I believe this will be a temporary fix until they actually fix powermetrics itself.

gavi avatar Jan 09 '24 22:01 gavi

Using a M3 Max here. The readings with this PR seem OK when the P-cores are actives, but they are overestimated when they are not. I think it is because the calculations do not take into account the P-Clusters and the P-Cores can also be down a part of the time, and that must be added to the "idle" time. I got something more plausible when I replace line 97

total_idle_ratio += cpu["idle_ratio"]

with this:

total_idle_ratio += cluster["down_ratio"] + (1 - cluster["down_ratio"]) * (cpu["idle_ratio"] + cpu["down_ratio"])

phgrosjean avatar Jan 10 '24 17:01 phgrosjean

@phgrosjean I think your change is much better. I am updating my PR

image

gavi avatar Jan 10 '24 17:01 gavi

Oh yes awesome. I noticed the down CPUs counter last night when I ran powermetrics manually to understand the output. Didn’t know how to account for them yet.

I did notice that the graph looks more accurate when I stress the computer to actually use the P-cores and that could explain what you just wrote.

Will try soon. Thank you!

On Wed, Jan 10, 2024 at 12:03 PM Philippe Grosjean @.***> wrote:

Using a M3 Max here. The readings with this PR seem OK when the P-cores are actives, but they are overestimated when they are not. I think it is because the calculations do not take into account the P-Clusters and the P-Cores can also be down a part of the time, and that must be added to the "idle" time. I got something more plausible when I replace line 97

total_idle_ratio += cpu["idle_ratio"]

with this:

total_idle_ratio += cluster["down_ratio"] + (1 - cluster["down_ratio"]) * (cpu["idle_ratio"] + cpu["down_ratio"])

— Reply to this email directly, view it on GitHub https://github.com/tlkh/asitop/pull/68#issuecomment-1885246502, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLJ5PU5N7PDC26IYKVG7H3YN3CUPAVCNFSM6AAAAABBGYINLCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGI2DMNJQGI . You are receiving this because you commented.Message ID: @.***>

chiltalk avatar Jan 10 '24 17:01 chiltalk

I updated the PR

gavi avatar Jan 10 '24 17:01 gavi

Looks a lot better to me! thank you both.

Screenshot 2024-01-10 at 1 04 18 PM

chiltalk avatar Jan 10 '24 17:01 chiltalk

@gavi thanks for the fix! would be great to see this merged.

iamaziz avatar Feb 22 '24 04:02 iamaziz

For anyone who are not sure how to port this changes to your own machine, just replace the parsers.py file with the changed parsers.py file in this PR, for reference, I installed asitop via pip and it's located at /opt/homebrew/lib/python3.11/site-packages/asitop for me. Then run asitop again in the terminal, you are good to go.

Ender-Wang avatar Mar 19 '24 11:03 Ender-Wang

pip install git+https://github.com/gavi/asitop.git should work too.

iamaziz avatar Mar 19 '24 18:03 iamaziz

Looking forward to this being merged and released, thanks @gavi !

Proryanator avatar Mar 25 '24 17:03 Proryanator

Looking forward to this being merged and released, thanks @gavi !

Not likely, seems the repo author is off the planet to Mars.

Ender-Wang avatar Mar 25 '24 17:03 Ender-Wang