Skip to content

Htop 3.4.0-dev not showing CPU percentage on apple silicon #1638

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

Open
Korrd opened this issue Mar 13, 2025 · 10 comments · May be fixed by #1691
Open

Htop 3.4.0-dev not showing CPU percentage on apple silicon #1638

Korrd opened this issue Mar 13, 2025 · 10 comments · May be fixed by #1691
Labels
bug 🐛 Something isn't working MacOS 🍏 MacOS / Darwin related issues

Comments

@Korrd
Copy link

Korrd commented Mar 13, 2025

Since upgrading to 3.4.0-dev, htop won't show CPU percentages on the processes' list.

sudo htop
Image

I'm running macOS Sequoia 15.3.2 (24D81) on an M4 Pro Macbook

This issue had been reported and fixed before, here #622. Maybe a resurgence?

@BenBE BenBE added bug 🐛 Something isn't working MacOS 🍏 MacOS / Darwin related issues labels Mar 13, 2025
@BenBE
Copy link
Member

BenBE commented Mar 13, 2025

Can you take a look with git bisect if you can locate where this issue got introduced? TIA.

@BenBE BenBE added the question ❔ Further information is requested label Mar 13, 2025
@Explorer09
Copy link
Contributor

Didn't see precisely where the error is through the screenshot. I have a M2 MacBook Pro with macOS Sequoia and didn't observe error on my side.

@Korrd
Copy link
Author

Korrd commented Mar 14, 2025

If you compare the CPU Usage bars to the CPU usage on the process list, you'll notice there are no processes reflecting the amount of CPU usage shown on the bars themselves.

Here's a better screenshot showing the disparity between CPU graph and reported CPU usage on process' list.

Image

@aestriplex
Copy link
Contributor

This is an actual problem on Apple silicon. I checked all the commits that touched DarwinProcess.c from the 3.3.0 tag on. It turned out that the problem is in this commit.
In particular, this behavior seems caused by having removed the #else block in Platform_calculateNanosecondsPerMachTick.
Between tonight and tomorrow morning I'll do some more investigations, because the running time seems to be correct (before it wasn't).

aestriplex added a commit to aestriplex/htop that referenced this issue Mar 18, 2025
@aestriplex
Copy link
Contributor

I reverted my previous commit. Now it shows a more reliable cpu percentage at a process level (or at least consistent with 3.3.0).
@BenBE @fasterit I wait to open a pr, because I wish to further investigate the Platform_calculateNanosecondsPerMachTick function. In the case of a program compiled directly for silicon, it should not run in compatibility mode (i.e. without rosetta); here's the compiler binary from my M2:

% file htop
htop: Mach-O 64-bit executable arm64

so perhaps it should be enough

...
else {
      // No workarounds needed, use the OS-provided value.
      mach_timebase_info(&info);
}
...

@aestriplex
Copy link
Contributor

The mach_timebase_info on Apple Silicon sets the structure correctly (125/3). Everything seems ok, both the cpu percentage and the running time (compared to top). Even if isRunningUnderRosetta2 should always be false, because the program is compiled for the right architecture each time, probably we can leave those controls there, just in case.
I'll open a pr with the commit reverted

@corneliusroemer
Copy link

corneliusroemer commented Apr 8, 2025

The title of this issue wasn't quite intuitive to me so I didn't spot that what I reported in #1664 is likely a duplicate of this issue here.

In my case I do see percentages for CPU, it's just that they are way too small since version 3.4.0 and on Apple silicon. Is that what this issue here is about? Why does it say "not showing percentage" when it is showing?

@Explorer09: Didn't see precisely where the error is through the screenshot.

That was also my issue, took me a while to identify the duplicate. I've got a GIF showing top vs htop showing that CPU reported by htop is ~40x too small:

Image

@BenBE The question label should be removed, I have the exact same issue, with homebrew and source compiled 3.4.0.

@Korrd
Copy link
Author

Korrd commented Apr 18, 2025

Is there a release date for this fix?

@BenBE
Copy link
Member

BenBE commented Apr 18, 2025

Details are in #1643, which won't be merged as is, as it reverts from one broken state to another broken state instead of providing an actual improvement …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working MacOS 🍏 MacOS / Darwin related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
@BenBE @Explorer09 @Korrd @corneliusroemer @aestriplex and others