htop-dev / htop

htop - an interactive process viewer
https://htop.dev/
GNU General Public License v2.0
6.48k stars 441 forks source link

CPU usage bars show less usage than expected #1208

Open grahamperrin opened 1 year ago

grahamperrin commented 1 year ago

Screenshot below:

image

Without bisecting, I wonder whether https://github.com/htop-dev/htop/commit/e207c8aebdcdb88bc8ab838e2ac3dd1774d6a618 (2023-03-04) produces the intended improvement in cases such as this.

Running at the time of the first shot:

cd /usr/src && time make -j4 buildworld > & buildworld.log && time make DISABLE_VULNERABILITIES=yes -j4 buildkernel > & buildkernel.log && tail buildworld.log && tail buildkernel.log


Later, whilst building lang/gcc12 using poudriere-bulk(8) with MAKE_JOBS enabled:

image

image

I'm fairly certain that usage of each CPU is at, or very close to, its maximum because I hear the fan(s) running fast for an extended period.

Environment

% uname -aKU
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #33 main-n261014-cd406ac94d8b: Sun Feb 19 01:35:14 GMT 2023     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400081 1400081
% 
grahamperrin commented 1 year ago

Hmm, this seems more reasonable, not long after an update to the OS:

image

FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #34 main-n261465-22bf2a479f68: Sun Mar 12 05:18:09 GMT 2023 grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400082 1400082

grahamperrin commented 1 year ago

With c878343784f23d7cb18ccec6aa034f01aee8069e (2023-04-05), two screenshots from yesterday (2023-04-11):

2023-04-11 01-25-28 htop, CPUs

2023-04-11 01-27-39 htop, CPUs

Probably running at the time:

poudriere bulk -j main -J 8 -Ctv emulators/virtualbox-ose

– with ALLOW_MAKE_JOBS=yes in /usr/local/etc/poudriere.conf.

Translated: with this allowance, I expect use of all four CPUs to be maximised for long periods.

In the situation pictured above:

cgzones commented 1 year ago

using stress(1) on FreeBSD 13.2 seems to report usage fine

grahamperrin commented 1 year ago

I might try stress(1) later, thanks.

In the meantime, screenshots from 14:07 and 14:10 this afternoon (again, whilst building and packaging software):

2023-04-15 14-07 more than 200 percent

2023-04-15 14-10 more than 200 percent

If you visualise the four chunks of used, combined, it's nowhere near the 200% used by two processes alone.


A few minutes later, CPU usage percentages presented by poudriere itself, during the final ~25 seconds of packaging texlive-texmf:

image

grahamperrin commented 1 year ago

Hmm, I just realised, I forgot to remove the patch file that came from:

https://github.com/htop-dev/htop/issues/1193#issuecomment-1454474359

It's now gone, and I have rebuilt htop.

Would there have been an adverse effect from building with the patch still present?

BenBE commented 1 year ago

Hmm, I just realised, I forgot to remove the patch file that came from:

https://github.com/htop-dev/htop/issues/1193#issuecomment-1454474359

It's now gone, and I have rebuilt htop.

Would there have been an adverse effect from building with the patch still present?

Nothing related to CPU usage …

grahamperrin commented 4 months ago

htop 3.4.0-dev-3.3.0-143-g2b4feef

This appears more realistic:

2024-07-01 03-39-43

BenBE commented 4 months ago

The large number of red (terminated) marked processes and the specifics I gather from your described work-load hints at the possibility that we're dealing with loads of short-lived processes here, thus many processes take CPU time but are never caught by htop when it scans for processes.

This could be resolved by explicit listening for short-lived processes with available kernel facilities (but that would require root and will not be available on most platforms).