Bug 469558

Summary: Wayland suffers from high CPU usage while doing trivial tasks
Product: [Plasma] kwin Reporter: medin <med.medin.2014>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kde, nate, xaver.hugl
Priority: NOR    
Version First Reported In: 5.27.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.0
Sentry Crash Report:
Attachments: Wayland suffers from high CPU usage while doing trivial tasks
drm_info_output.txt

Description medin 2023-05-09 22:55:54 UTC
Created attachment 158815 [details]
Wayland suffers from high CPU usage while doing trivial tasks

See attached video for more info.
Comment 1 Nate Graham 2023-05-15 19:37:02 UTC
What kind of GPU are you using?
Comment 2 medin 2023-05-15 19:44:36 UTC
(In reply to Nate Graham from comment #1)
> What kind of GPU are you using?

My laptop has CPU i3-1005g1 running Manjaro, the same happens with another laptop with i3-5005u running KUbuntu.
Comment 3 Nate Graham 2023-05-16 13:32:26 UTC
Interesting, I'm using a i7-10510U which is the same generation as the first processor you mentioned, and I don't experience these issues. i7 vs i3, though.
Comment 4 Zamundaaa 2023-05-16 15:08:44 UTC
Please attach the output of
> journalctl --user-unit plasma-kwin_wayland --boot 0
after running the Wayland session for a bit.
The output of drm_info (https://gitlab.freedesktop.org/emersion/drm_info) would also be useful
Comment 5 medin 2023-05-16 19:32:28 UTC
(In reply to Zamundaaa from comment #4)
> Please attach the output of
> > journalctl --user-unit plasma-kwin_wayland --boot 0
> after running the Wayland session for a bit.


May 16 21:00:01 manjaro-med systemd[2932]: Starting KDE Window Manager...
May 16 21:00:01 manjaro-med systemd[2932]: Started KDE Window Manager.
May 16 21:00:01 manjaro-med kwin_wayland[2964]: No backend specified, automatically choosing drm
May 16 21:00:01 manjaro-med kwin_wayland[2964]: OpenGL vendor string:                   Intel
May 16 21:00:01 manjaro-med kwin_wayland[2964]: OpenGL renderer string:                 Mesa Intel(R) UHD Graphics (ICL GT1)
May 16 21:00:01 manjaro-med kwin_wayland[2964]: OpenGL version string:                  4.6 (Core Profile) Mesa 23.0.3
May 16 21:00:01 manjaro-med kwin_wayland[2964]: OpenGL shading language version string: 4.60
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Driver:                                 Intel
May 16 21:00:01 manjaro-med kwin_wayland[2964]: GPU class:                              Ice Lake
May 16 21:00:01 manjaro-med kwin_wayland[2964]: OpenGL version:                         4.6
May 16 21:00:01 manjaro-med kwin_wayland[2964]: GLSL version:                           4.60
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Mesa version:                           23.0.3
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Linux kernel version:                   6.3
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Requires strict binding:                no
May 16 21:00:01 manjaro-med kwin_wayland[2964]: GLSL shaders:                           yes
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Texture NPOT support:                   yes
May 16 21:00:01 manjaro-med kwin_wayland[2964]: Virtual Machine:                        no
May 16 21:00:01 manjaro-med kwin_wayland[2964]: kwin_xkbcommon: XKB: inet:323:58: unrecognized keysym "XF86EmojiPicker"
May 16 21:00:01 manjaro-med kwin_wayland[2964]: kwin_xkbcommon: XKB: inet:324:58: unrecognized keysym "XF86Dictate"
May 16 21:00:01 manjaro-med kwin_wayland_wrapper[2988]: (WW) Option "-listen" for file descriptors is deprecated
May 16 21:00:01 manjaro-med kwin_wayland_wrapper[2988]: Please use "-listenfd" instead.
May 16 21:00:01 manjaro-med kwin_wayland_wrapper[2988]: (WW) Option "-listen" for file descriptors is deprecated
May 16 21:00:01 manjaro-med kwin_wayland_wrapper[2988]: Please use "-listenfd" instead.
May 16 21:00:02 manjaro-med kwin_wayland_wrapper[3008]: The XKEYBOARD keymap compiler (xkbcomp) reports:
May 16 21:00:02 manjaro-med kwin_wayland_wrapper[3008]: > Warning:          Unsupported maximum keycode 708, clipping.
May 16 21:00:02 manjaro-med kwin_wayland_wrapper[3008]: >                   X11 cannot support keycodes above 255.
May 16 21:00:02 manjaro-med kwin_wayland_wrapper[3008]: Errors from xkbcomp are not fatal to the X server



> The output of drm_info (https://gitlab.freedesktop.org/emersion/drm_info)
> would also be useful

I cannot list all lines due to comment limit, so I attached as drm_info_output.txt.
Comment 6 medin 2023-05-16 19:33:55 UTC
Created attachment 159013 [details]
drm_info_output.txt
Comment 7 medin 2023-05-16 19:48:46 UTC
We(In reply to Nate Graham from comment #3)
> Interesting, I'm using a i7-10510U which is the same generation as the first
> processor you mentioned, and I don't experience these issues. i7 vs i3,
> though.

With another old Acer laptop using Pentium Dual-Core CPU T4400 @ 2.20GHz/6GB RAM, it runs fine on Manjaro KDE with X11 and can smoothly do basic tasks like browsing with Firefox and typing on LibreOffice and using Gimp and Inkscape, but switching to Wayland makes the machine totally laggy.
Comment 8 Zamundaaa 2023-05-17 14:18:12 UTC
Okay, so KWin is using OpenGL, and not using software rendering. If you run
> udevadm monitor
are there any events being printed?
Comment 9 medin 2023-05-17 14:42:08 UTC
(In reply to Zamundaaa from comment #8)
> Okay, so KWin is using OpenGL, and not using software rendering. If you run
> > udevadm monitor
> are there any events being printed?

It displays just the following lines without any events:

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent


What I can add is that on T4400 the following message appears a lot in journalctl:
May 17 15:34:50 manjaro-med kwin_wayland[19855]: kwin_screencast: Dropping a screencast frame because the compositor is slow
Comment 10 Zamundaaa 2023-05-17 15:43:49 UTC
Okay, so udev events triggering stuff in KWin can be ruled out. Can you try putting
> KWIN_DRM_PREFER_COLOR_DEPTH=24
and
>  KWIN_DRM_USE_MODIFIERS=0
and
> KWIN_DRM_NO_AMS=1
into /etc/environment and see if that makes a difference? Use only one at a time, and reboot after changing it
Comment 11 medin 2023-05-17 23:10:11 UTC
(In reply to Zamundaaa from comment #10)
> Okay, so udev events triggering stuff in KWin can be ruled out. Can you try
> putting
> > KWIN_DRM_PREFER_COLOR_DEPTH=24
> and
> >  KWIN_DRM_USE_MODIFIERS=0
> and
> > KWIN_DRM_NO_AMS=1
> into /etc/environment and see if that makes a difference? Use only one at a
> time, and reboot after changing it


The 3 parameters cause close CPU usage (from 12% to 25%) with simply basic tasks like passing the mouse over panel items, displaying tooltips and thumbnails and opening/closing kickoff. But "KWIN_DRM_NO_AMS=1" has not great but a little better result compared to the two others. And the most noticeable is that setting "KWIN_DRM_NO_AMS=1" helped greatly in fixing the mouse laggy movements and improved a lot its pointer precision while moving and clicking.
Comment 12 Nate Graham 2023-05-18 16:32:29 UTC
FWIW to the extent that I do experience a mild version of this from time to time with my 10th gen intel i7 CPU, KWIN_DRM_NO_AMS=1 makes it much worse.
Comment 13 Zamundaaa 2024-04-24 16:34:56 UTC
Does this still happen with Plasma 6?
Comment 14 medin 2024-04-25 12:54:32 UTC
(In reply to Zamundaaa from comment #13)
> Does this still happen with Plasma 6?

Truthfully, Plasma 6 performance is quite amazing, at least on my laptops running on intel CPUs.

I tested on two oldest models (both gen5), and Plasma 6.0.4 performs basic tasks without any high CPU usage (under 6%). The surprise is that Wayland feels much smoother and fast than X11.
Comment 15 Nate Graham 2024-04-25 12:59:18 UTC
Excellent, that sounds like a no to me!