Bug 486214 - High CPU usage on kwin_wayland when idle
Summary: High CPU usage on kwin_wayland when idle
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 6.0.4
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 493769 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-04-27 17:42 UTC by Bill
Modified: 2024-10-23 19:58 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
hotspot logs (3.75 MB, application/octet-stream)
2024-04-27 17:46 UTC, Bill
Details
btop_screenshot (1.04 MB, image/png)
2024-04-27 17:47 UTC, Bill
Details
intel_gpu_top_screenshot (579.92 KB, image/png)
2024-04-27 17:47 UTC, Bill
Details
powertop_screenshot (765.63 KB, image/png)
2024-04-27 17:49 UTC, Bill
Details
hotspot flamegraph firefox playback (353.70 KB, image/png)
2024-06-12 12:44 UTC, Dashon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bill 2024-04-27 17:42:48 UTC
SUMMARY


STEPS TO REPRODUCE
1. Use system as normal
2. Btop shows high cpu and power usgae by kwin_wayland
3. 

OBSERVED RESULT
kwin_wayland usage cpu constantly, causing higher power draw, stoping cpu from deeper sleep state

EXPECTED RESULT
kwin_wayland should not be using cpu consultant, it should allow cpu to fall into deeper sleep state when no in active use

SOFTWARE/OS VERSIONS

Operating System: Fedora Linux 40
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.8.7-300.fc40.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × 12th Gen Intel® Core™ i5-1240P
Memory: 31.1 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: Framework
Product Name: Laptop (12th Gen Intel Core)
System Version: A4

ADDITIONAL INFORMATION
Comment 1 Bill 2024-04-27 17:46:09 UTC
Created attachment 168952 [details]
hotspot logs
Comment 2 Bill 2024-04-27 17:47:08 UTC
Created attachment 168953 [details]
btop_screenshot
Comment 3 Bill 2024-04-27 17:47:56 UTC
Created attachment 168954 [details]
intel_gpu_top_screenshot
Comment 4 Bill 2024-04-27 17:49:05 UTC
Created attachment 168955 [details]
powertop_screenshot

I left the system to idle for about 10 mins, then took this.
Comment 5 Zamundaaa 2024-04-28 22:13:05 UTC
I don't see anything particularly weird in the flamegraph, most of the CPU time is in compositing and processing Wayland events. There is a somewhat odd QThreadPool thing in there taking up a not insignificant part of CPU time, but it's not enough to cause this issue
Comment 6 Bill 2024-04-30 12:24:09 UTC
(In reply to Zamundaaa from comment #5)
> I don't see anything particularly weird in the flamegraph, most of the CPU
> time is in compositing and processing Wayland events. There is a somewhat
> odd QThreadPool thing in there taking up a not insignificant part of CPU
> time, but it's not enough to cause this issue

I've made few more observations since.
The issue is not persistent and constant as it was when I reported it, that seem to have been the right moment where I caught it in full swing.
laptop was asleep for few hours after reporting this bug and I didn't see the same CPU usage by kwin_wayland that day. 
It does reaper occasionality, especially where it does uses significant cpu time just sitting around idling for some reason?
Comment 7 Dashon 2024-06-12 12:44:27 UTC
Created attachment 170414 [details]
hotspot flamegraph firefox playback
Comment 8 Dashon 2024-06-12 12:49:14 UTC
Sorry wrong report
Comment 9 Dashon 2024-08-04 03:56:07 UTC
Would help to upload a copy of my perf.data file?
Comment 10 TraceyC 2024-10-22 20:33:17 UTC
*** Bug 493769 has been marked as a duplicate of this bug. ***
Comment 11 TraceyC 2024-10-22 23:15:54 UTC
I have a KDE Neon Stable VM that has this issue. It was suffering from the same thing previously, but the high CPU usage went away (probably from the fix in bug 493295) and has returned in the last few days.

kwin_wayland takes 180-200% CPU from system start, and then continuously

I've got hotpot installed, but I'm not sure how to get data out of it that would be useful. If I can provide data from it, just let me know what you need.

Plasma 6.2.1
Frameworks 6.7.0
Qt 6.7.2
Wayland

Given that I'm seeing constant high CPU usage, my system might have a different root cause.
Comment 12 Oded Arbel 2024-10-23 14:04:25 UTC
(In reply to TraceyC from comment #11)
> I've got hotpot installed, but I'm not sure how to get data out of it that
> would be useful. If I can provide data from it, just let me know what you
> need.

I tried `hotspot`, but for some reason it won't let me attach to `kwin_wayland` - only to `kwin_wayland_wrapper` and when I do that I get no results (I think because `kwin_wayland_wrapper` doesn't actually do anything unless `kwin_wayland` crashes).

You can use `perf` to generate the call trace data directly, and then - if you want - you can load it in hotspot. I use this command to capture 60 seconds of execution data:

sudo perf record -F 1000 -p $(pidof kwin_wayland) -g -- sleep 60
Comment 13 TraceyC 2024-10-23 19:58:48 UTC
Thanks Oded.
Here's the data I got from the VM, let me know if you want any other data.


Samples: 113K of event 'cycles:P', Event count (approx.): 333196569442
  Children      Self  Command          Shared Object                 Symbol
+   49.66%     0.00%  llvmpipe-1       libc.so.6                     [.] clone3
+   49.66%     0.00%  llvmpipe-1       libc.so.6                     [.] start_thread
+   49.66%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17c51d6fc
+   49.65%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb485b7
+   49.56%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4836b
+   49.46%     0.00%  llvmpipe-0       libc.so.6                     [.] clone3
+   49.46%     0.00%  llvmpipe-0       libc.so.6                     [.] start_thread
+   49.46%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17c51d6fc
+   49.43%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb485b7
+   49.33%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4836b
+   40.21%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb47d91
+   40.13%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb47d91
+    6.60%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4a3e6
+    6.53%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4a3e6
+    3.93%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4a9c4
+    3.86%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4a9c4
+    3.00%     2.98%  llvmpipe-1       [JIT] tid 2605                [.] 0x000079a186696d60
+    2.99%     2.96%  llvmpipe-0       [JIT] tid 2605                [.] 0x000079a186696d60
+    1.41%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb488d6
+    1.30%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb488d6
+    1.24%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4ae57
+    1.21%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4ae57
+    1.14%     1.13%  llvmpipe-1       [JIT] tid 2605                [.] 0x000079a17e5f57a9
+    1.12%     1.11%  llvmpipe-0       [JIT] tid 2605                [.] 0x000079a17e5f57a9
+    1.06%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb49b46
+    1.05%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb49b46
+    0.82%     0.00%  kwin_wayland     kwin_wayland                  [.] _start
+    0.82%     0.00%  kwin_wayland     libc.so.6                     [.] __libc_start_main@@GLIBC_2.34
+    0.82%     0.00%  kwin_wayland     libc.so.6                     [.] __libc_start_call_main
+    0.82%     0.00%  kwin_wayland     kwin_wayland                  [.] main
+    0.82%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QCoreApplication::exec()
+    0.82%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QEventLoop::exec(QFlags<QEventLoop::Proces
+    0.82%     0.00%  kwin_wayland     libQt6Gui.so.6.7.2            [.] QUnixEventDispatcherQPA::processEvents(QFl
+    0.82%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QEventDispatcherUNIX::processEvents(QFlags
+    0.81%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] 0x000079a195264d34
+    0.80%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QCoreApplication::notifyInternal2(QObject*
+    0.80%     0.00%  kwin_wayland     libQt6Widgets.so.6.7.2        [.] QApplicationPrivate::notify_helper(QObject
+    0.77%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QObject::event(QEvent*)
+    0.77%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QTimerInfoList::activateTimers()
+    0.77%     0.00%  kwin_wayland     libQt6Core.so.6.7.2           [.] QTimer::timeout(QTimer::QPrivateSignal)
+    0.77%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::RenderLoopPrivate::dispatch()
+    0.77%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::RenderLoop::frameRequested(KWin::Ren
+    0.77%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::WaylandCompositor::composite(KWin::R
+    0.72%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4b570
+    0.72%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb49fce
+    0.72%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4b570
+    0.69%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb49fce
+    0.69%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4ade0
+    0.66%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4b5ec
+    0.65%     0.00%  llvmpipe-1       kms_swrast_dri.so             [.] 0x000079a17cb4b4cf
+    0.65%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4ade0
+    0.64%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4b4cf
+    0.62%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::Compositor::paintPass(KWin::RenderLa
+    0.62%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::SceneDelegate::paint(KWin::RenderTar
+    0.62%     0.06%  llvmpipe-0       [kernel.kallsyms]             [k] asm_exc_page_fault
+    0.62%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::WorkspaceScene::paint(KWin::RenderTa
+    0.61%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::WorkspaceScene::paintSimpleScreen(KW
+    0.61%     0.07%  llvmpipe-1       [kernel.kallsyms]             [k] asm_exc_page_fault
+    0.60%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::WorkspaceScene::paintWindow(KWin::Re
+    0.60%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::ItemRendererOpenGL::renderItem(KWin:
+    0.59%     0.00%  llvmpipe-0       kms_swrast_dri.so             [.] 0x000079a17cb4b5ec
+    0.55%     0.00%  llvmpipe-0       [kernel.kallsyms]             [k] exc_page_fault
+    0.54%     0.00%  llvmpipe-0       [kernel.kallsyms]             [k] do_user_addr_fault
+    0.53%     0.00%  llvmpipe-1       [kernel.kallsyms]             [k] exc_page_fault
+    0.52%     0.00%  llvmpipe-1       [kernel.kallsyms]             [k] do_user_addr_fault
     0.50%     0.01%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::ItemRendererOpenGL::createRenderNode
     0.48%     0.00%  kwin_wayland     libkwin.so.6.2.1              [.] KWin::SurfaceItem::preprocess()