Summary: | Individual Core Usage incorrectly shows 100% CPU usage, disagreeing with htop and System Monitor | ||
---|---|---|---|
Product: | [Frameworks and Libraries] ksystemstats | Reporter: | Andrew Kelley <andrew> |
Component: | General | Assignee: | Plasma Bugs List <plasma-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | ahiemstra, kde, nate, shu72 |
Priority: | NOR | ||
Version: | 6.2.4 | ||
Target Milestone: | --- | ||
Platform: | NixOS | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/plasma/ksystemstats/-/commit/ab95630786a6a89f12681adc7fe59a643c382267 | Version Fixed In: | 6.3.0 |
Sentry Crash Report: | |||
Attachments: |
screenshot
screenshot with htop and system monitor |
Description
Andrew Kelley
2024-12-11 23:01:21 UTC
The widget doesn't measure apps but rather than whole system. Apps can still be consuming CPU even when they're idle, too. Can you attach a new screenshot that shows the output of htop and System Monitor disagreeing with what the widget is saying? Created attachment 176567 [details]
screenshot with htop and system monitor
Here is the requested screenshot.
To be clear when I use the word "idle" here, I mean "using 0% CPU". Updated steps to reproduce now that ghostty is released as free and open source software: First, ensure x11 or wayland, libadwaita, pkg-config, and gtk4 development system libraries are installed. Build from source: ``` wget https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz tar xf zig-linux-x86_64-0.13.0.tar.xz git clone https://github.com/ghostty-org/ghostty/ cd ghostty git checkout v1.0.0 ../zig-linux-x86_64-0.13.0/zig build ./zig-out/bin/ghostty ``` Observe 2 apparently pegged CPU cores per open window. Run htop and notice ghostty actually is idle. Run System Monitor and notice ghostty is actually idle. For what it's worth I can confirm this happening on my system too: Operating System: openSUSE Tumbleweed 20241224 KDE Plasma Version: 6.2.4 KDE Frameworks Version: 6.9.0 Qt Version: 6.8.1 Kernel Version: 6.12.6-1-default (64-bit) Graphics Platform: Wayland Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor Memory: 15.5 GiB of RAM Graphics Processor: AMD Radeon RX 6600 XT Manufacturer: Micro-Star International Co., Ltd. Product Name: MS-7C56 System Version: 6.0 Another screenshot that illustrates the problem: https://ibb.co/bzdkbvS On the dashboard the CPU usage is constantly at around 17 percent while Ghostty is running (and that is mirrored when using the applet "Individual Core Usage" which shows 2 of 12 cores constantly busy with Ghostty). But the actual list of processes (or htop) show that Ghostty is basically idle at zero percent cpu usage. This is the first time I've seen this happen though. No other software than Ghostty leads to this false reporting of cpu usage. The CPU usage values are computed by reading `/proc/stat` which contains the amount of time the different cores have been in different states. We divide these values into three groups: system, user and wait and calculate the percentages of these. The total CPU usage percentage is then these three added together. Now, one of the values in "wait" is "iowait" which is the amount of time spent idle but while some process is waiting on IO. Now, I don't know what GhostTTY is doing but the end result is that it's causing almost 100% iowait on a core. This then results in the total usage sensor reporting 100% usage. While we should probably remove iowait from the CPU usage accounting (as it is not actually doing anything), there *also* seems to be a problem in GhosTTY, other processes don't cause this much iowait. Note that this is actually also visible in top, the "%wa" statistic at the top shows ~16% for my machine when ghostty is running. A possibly relevant merge request was started @ https://invent.kde.org/plasma/ksystemstats/-/merge_requests/104 Seems to be an io_uring bug in the kernel: https://github.com/axboe/liburing/issues/943 Perhaps worth working around it for now? Yeah the above MR drops iowait from total usage since it makes little sense anyway. Thanks for working on that! Git commit 2b6c91971a43d1d245ff284006cead43d2f71260 by Arjen Hiemstra. Committed on 28/01/2025 at 15:50. Pushed by ahiemstra into branch 'master'. plugins/cpu: Remove "wait" from total CPU usage sensors "wait" consistant mainly of "iowait" which is time the CPU is idle but something's waiting on IO. This means it's not really actual CPU load, so we should count it towards the total load. M +1 -1 plugins/cpu/usagecomputer.cpp https://invent.kde.org/plasma/ksystemstats/-/commit/2b6c91971a43d1d245ff284006cead43d2f71260 Git commit ab95630786a6a89f12681adc7fe59a643c382267 by Arjen Hiemstra. Committed on 28/01/2025 at 16:00. Pushed by ahiemstra into branch 'Plasma/6.3'. plugins/cpu: Remove "wait" from total CPU usage sensors "wait" consistant mainly of "iowait" which is time the CPU is idle but something's waiting on IO. This means it's not really actual CPU load, so we should count it towards the total load. (cherry picked from commit 2b6c91971a43d1d245ff284006cead43d2f71260) Co-authored-by: Arjen Hiemstra <ahiemstra@heimr.nl> M +1 -1 plugins/cpu/usagecomputer.cpp https://invent.kde.org/plasma/ksystemstats/-/commit/ab95630786a6a89f12681adc7fe59a643c382267 |