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.