Htop 3.4.0-dev not showing CPU percentage on apple silicon
Since upgrading to 3.4.0-dev, htop won't show CPU percentages on the processes' list.
sudo htop
I'm running macOS Sequoia 15.3.2 (24D81) on an M4 Pro Macbook
This issue had been reported and fixed before, here https://github.com/htop-dev/htop/issues/622. Maybe a resurgence?
Can you take a look with git bisect if you can locate where this issue got introduced? TIA.
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.
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.
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).
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);
}
...
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
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:
@BenBE The question label should be removed, I have the exact same issue, with homebrew and source compiled 3.4.0.
Is there a release date for this fix?
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 …
@BenBE Any updates on this ...?
I see that its associated PR is ready for merge. Is there anything else blocking it?
There are two PRs associated with this issue: #1643 & #1691