Wayland - high cpu usage

No matter the driver version, I’ve always had an exceptionally higher cpu usage in the compositor with wayland than in X11. The main compositors I used are KWin and wlroots, now aquamarine, from Hyprland. Hyprland has a bit lower CPU usage but not by much.
When I say high, X11 is hovering at a constant ~1.x% while wayland is at 20-50%. The 50% can be triggered in Firefox, moving the mouse around.

Can someone clue me in why that is? And better yet, how can I reduce or fix this?

2 Likes

I have the same problem on Sway, but not on Gnome.
If I move the mouse or something is moving on the screen, Sway’s CPU usage is 30% to 50%.
If I use the Intel card instead, Sway’s CPU usage stays under 2%.

GPU: GeForce RTX 3050 Ti
CPU: i7-11850H
Distro: NixOS
Driver: 560.31.02
Kernel: 6.10.14

Let me know if any other info is needed. I can also thinker with wlroots code if experimentation is needed :)

EDIT: perf shows that most of the CPU time is spent on the nvidia driver:

I’ve tried using Nouveau and the CPU usage of stays under 2%, so this seems like a bug on the Nvidia driver indeed.

Hotspot attached to kwin_wayland shows this:

which goes into: open-gpu-kernel-modules/src/nvidia/arch/nvalloc/unix/src/osapi.c at 9d0b0414a5304c3679c5db9d44d2afba8e58cc1b · NVIDIA/open-gpu-kernel-modules · GitHub

I can’t tell which op call is made. Would be great if a Nvidia dev could look into this. kwin_wayland when nothing happens is <2% but as soon as some redraw is going on it’s at 25-30% (of 1 core)
This is unusually high and has been for quite some time.

Same situation on my computer. Last apt operations on my side was:

Start-Date: 2025-05-29 20:13:21
Requested-By: vitex (1000)
Remove: xtrans-dev:amd64 (1.4.0-1), openjdk-21-jdk-headless:amd64 (21.0.7+6-1), mlock:amd64 (8:2007f~dfsg-7.1+0~20250310.3+debian13~1.gbpe1afca), libxcb1-dev:amd64 (1.17.0-2+b1), libice-dev:amd64 (2:1.1.1-1), openjdk-21-jdk:amd64 (21.0.7+6-1), libsm-dev:amd64 (2:1.2.6-1), libxau-dev:amd64 (1:1.0.11-1), xorg-sgml-doctools:amd64 (1:1.11-1.1), uuid-dev:amd64 (2.41-5), libx11-dev:amd64 (2:1.8.12-1), libc-client2007e:amd64 (8:2007f~dfsg-7.1+0~20250310.3+debian13~1.gbpe1afca), libxt-dev:amd64 (1:1.2.1-1.2+b2), libxdmcp-dev:amd64 (1:1.1.5-1), x11proto-dev:amd64 (2024.1-1), php-sqlite3:amd64 (2:8.4+96+0~20250402.56+debian13~1.gbp84a5b7)
End-Date: 2025-05-29 20:13:24

Start-Date: 2025-05-29 20:13:37
Requested-By: vitex (1000)
End-Date: 2025-05-29 20:13:37

Start-Date: 2025-05-29 20:14:37
Requested-By: vitex (1000)
Install: nvidia-opencl-icd:amd64 (575.51.03-1, automatic), libnvcuvid1:amd64 (575.51.03-1, automatic), libnvidia-opticalflow1:amd64 (575.51.03-1, automatic), libnvidia-fbc1:amd64 (575.51.03-1, automatic), libnvoptix1:amd64 (575.51.03-1, automatic), libnvidia-ptxjitcompiler1:amd64 (575.51.03-1, automatic), libnvidia-ptxjitcompiler1:i386 (575.51.03-1, automatic), libnvidia-pkcs11-openssl3:amd64 (575.51.03-1, automatic), libnvidia-nvvm4:amd64 (575.51.03-1, automatic), libnvidia-encode1:amd64 (575.51.03-1, automatic), libnvidia-sandboxutils:amd64 (575.51.03-1, automatic), libnvidia-nvvm704:amd64 (575.51.03-1, automatic), libnvidia-present:amd64 (575.51.03-1, automatic), nvidia-driver-cuda:amd64 (575.51.03-1, automatic), libcuda1:amd64 (575.51.03-1, automatic), libcuda1:i386 (575.51.03-1, automatic), libcudadebugger1:amd64 (575.51.03-1, automatic), nvidia-persistenced:amd64 (575.51.03-1, automatic)
Remove: libnvidia-egl-gbm1:amd64 (1.1.2.1-1), libnvidia-egl-gbm1:i386 (1.1.2.1-1), libnvidia-egl-xcb1:amd64 (570.124.06-1), libnvidia-egl-xcb1:i386 (570.124.06-1), libgles-nvidia1:amd64 (575.51.03-1), libgles-nvidia1:i386 (575.51.03-1), libgles-nvidia2:amd64 (575.51.03-1), libgles-nvidia2:i386 (575.51.03-1), libnvidia-vksc-core:amd64 (575.51.03-1), nvidia-egl-icd:amd64 (575.51.03-1), libnvidia-api1:amd64 (575.51.03-1), libnvidia-egl-wayland1:amd64 (1:1.1.19-1), libnvidia-egl-wayland1:i386 (1:1.1.19-1), libgles1:amd64 (1.7.0-1+b2), libgles1:i386 (1.7.0-1+b2), libgles2:i386 (1.7.0-1+b2), nvidia-driver-libs:amd64 (575.51.03-1), nvidia-driver-libs:i386 (575.51.03-1), nvidia-driver:amd64 (575.51.03-1), libnvidia-allocator1:amd64 (575.51.03-1), libnvidia-allocator1:i386 (575.51.03-1), libnvidia-ngx1:amd64 (575.51.03-1), libopengl0:i386 (1.7.0-1+b2), libnvidia-egl-xlib1:amd64 (570.124.06-1), libnvidia-egl-xlib1:i386 (570.124.06-1), libegl-nvidia0:amd64 (575.51.03-1), libegl-nvidia0:i386 (575.51.03-1), xserver-xorg-video-nvidia:amd64 (575.51.03-1)
End-Date: 2025-05-29 20:14:46