htop icon indicating copy to clipboard operation
htop copied to clipboard

CPU usage bars show less usage than expected

Open grahamperrin opened this issue 2 years ago • 8 comments

Screenshot below:

  • GKrellM sysutils/gkrellm2 2.3.11_1 in the foreground
  • htop sysutils/htop 3.2.2_1 in the mid-ground
  • htop 3.3.0-dev in the background, built from source 2023-03-06.

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

  • note, the CPU row in output from top(1).

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 avatar Mar 12 '23 09:03 grahamperrin

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

image

  • note, 299% kernel according to gkrelltop.

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 avatar Mar 12 '23 11:03 grahamperrin

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:

  • GKrellM painted a truer picture than htop.

grahamperrin avatar Apr 12 '23 06:04 grahamperrin

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

cgzones avatar Apr 12 '23 18:04 cgzones

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 avatar Apr 15 '23 13:04 grahamperrin

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?

grahamperrin avatar Apr 19 '23 17:04 grahamperrin

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 …

BenBE avatar Apr 19 '23 17:04 BenBE

htop 3.4.0-dev-3.3.0-143-g2b4feef

This appears more realistic:

2024-07-01 03-39-43

grahamperrin avatar Jul 01 '24 02:07 grahamperrin

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).

BenBE avatar Jul 01 '24 12:07 BenBE

We're closing stale / probably solved issues while updating the release schedule. This one seems to be in that batch. Please feel free to reopen with new information if the issue is still showing in the current git main head.

fasterit avatar Jan 20 '25 14:01 fasterit