htop icon indicating copy to clipboard operation
htop copied to clipboard

Dynamic display of online CPUs in CPU meter

Open BenBE opened this issue 2 years ago • 2 comments

This is a follow up to #993 / #995 / #1195 / #1197 aimed at systems with dynamic power management of CPU cores.

When a system has many cores and most of them are offline (e.g. due to power saving mode or because of containerization) these offline CPUs should be hidden while offline, but shown once first active (or recently active). An additional color coding similar to #74 / #241 might be added to indicate cores that recently became active or were recently disabled.

Basically, what is needed is:

  1. Track which cores have been seen online (and when)
  2. Hide cores that have not been online (recently)
  3. Implement some highlighting similar to #74 / #241 for CPU cores that have recently changed their state (possibly with flapping detection when the state changes regularly)
  4. Create some configuration for this additional behavior as either an additional type of CPU meter OR as part of the normal CPU meters
  5. Better display CPU node hierarchy information (physical id, core id, apic id, core type re SMT/BIG.little)

/cc @fasterit

BenBE avatar Feb 25 '23 22:02 BenBE

As explained in my comment here, I think the main problem is that the Linux version of updateCPUcount() checks for available processors instead (equivalent to sysconf(_SC_NPROCESSORS_CONF)) while the Solaris version of that function checks for online processors by correctly using sysconf(_SC_NPROCESSORS_ONLN).

I would simply switch to using sysconf(_SC_NPROCESSORS_ONLN) on Linux as well instead of parsing through /sys.

glaubitz avatar Nov 15 '23 15:11 glaubitz

@glaubitz That won't work as that will just reintroduce https://github.com/htop-dev/htop/issues/1195 again, but worse, as commented on the PR draft that https://github.com/htop-dev/htop/pull/1394 supersedes.
Either of the two PRs is not related to this issue, as neither PR actually hides the offline threads from the view, it's just about marking them offline correctly.

While this is being plumbed it would be nice to fix the terminology - CPU, socket, cores, threads, … - at least the linux Machine file has "cpu" used everywhere for threads.

C0rn3j avatar Jan 31 '24 10:01 C0rn3j