diff options
author | Arnavion <arnavion@gmail.com> | 2019-08-10 22:19:32 -0700 |
---|---|---|
committer | Arnavion <arnavion@gmail.com> | 2019-08-10 22:19:32 -0700 |
commit | 81b64691a7ee55e5c665ac78290495b0aea946d7 (patch) | |
tree | dc534595cc17c25bbf6cad0e978eda1a9ea419c8 /linux/LinuxProcessList.h | |
parent | 909bb86f05c20f0ec6f5d55994065a293932ce21 (diff) |
Move sysfs-reading code to LinuxProcessList.c and add average frequency.
This way the frequency is read from sysfs only once per update cycle
instead of every time the UI is redrawn.
This also changes the code to read from /proc/cpuinfo instead. This is because
reading from scaling_cur_freq stalls for 10ms if the previous read for the file
was more than one second ago. [1] Since htop's update cycle is
longer than that, it would cause the read of each CPU's scaling_cur_freq file
to block the UI for 20ms. This easily led to a noticeable half-second lag on
a 20+ CPU machine.
/proc/cpuinfo also has a 10ms delay, but this applies for the whole file
so the delay does not scale with the number of CPUs. [2]
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4815d3c56d1e10449a44089a47544d9ba84fad0d
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7d5905dc14a87805a59f3c5bf70173aac2bb18f8
Diffstat (limited to 'linux/LinuxProcessList.h')
-rw-r--r-- | linux/LinuxProcessList.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index f30b487d..ae36b354 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -48,6 +48,8 @@ typedef struct CPUData_ { unsigned long long int softIrqPeriod; unsigned long long int stealPeriod; unsigned long long int guestPeriod; + + double frequency; } CPUData; typedef struct TtyDriver_ { @@ -73,6 +75,10 @@ typedef struct LinuxProcessList_ { #define PROCDIR "/proc" #endif +#ifndef PROCCPUINFOFILE +#define PROCCPUINFOFILE PROCDIR "/cpuinfo" +#endif + #ifndef PROCSTATFILE #define PROCSTATFILE PROCDIR "/stat" #endif |