Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gavi
Copy link

@gavi gavi commented Dec 29, 2023

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 gavi mentioned this pull request Dec 29, 2023
@gavi
Copy link
Author

gavi commented Dec 29, 2023

Before fix on M3 Max (40 core GPU)

image

After fix

image

@ivanfioravanti
Copy link

please @tlkh merge this one 🙏

@samarthm314
Copy link

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

@chiltalk
Copy link

chiltalk commented Jan 9, 2024

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

@gavi
Copy link
Author

gavi commented Jan 9, 2024

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.

@phgrosjean
Copy link

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"])

@gavi
Copy link
Author

gavi commented Jan 10, 2024

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

image

@chiltalk
Copy link

chiltalk commented Jan 10, 2024 via email

@gavi
Copy link
Author

gavi commented Jan 10, 2024

I updated the PR

@chiltalk
Copy link

chiltalk commented Jan 10, 2024

Looks a lot better to me! thank you both.

Screenshot 2024-01-10 at 1 04 18 PM

@iamaziz
Copy link

iamaziz commented Feb 22, 2024

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

@Ender-Wang
Copy link

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.

@iamaziz
Copy link

iamaziz commented Mar 19, 2024

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

@Proryanator
Copy link

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

@Ender-Wang
Copy link

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

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

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.

None yet

8 participants