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: | ASSIGNED --- | ||
Severity: | major | CC: | ahiemstra, kde, nate, shu72 |
Priority: | NOR | ||
Version: | 6.2.4 | ||
Target Milestone: | --- | ||
Platform: | NixOS | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
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 |