Contributing to kwin_wayland, improving perf

Hi. I’ve been running kde/plasma for years. I just updated to Fedora 40 and tried kwin_wayland. It’s exciting to see it running and quite usable although still a bit laggy. I’d be interested to debug/fix some things myself. I read through CONTRIBUTING.md and have some drm and compositing experience. Am i right in assuming I’ll want a remote machine and ssh to debug and profile? Nesting wouldn’t test drm and trying to reserve and use multiple outputs/monitors might be possible but would be complex to set up.

Could someone point me to some instructions for minimally launching kwin_wayland and some common and simple test apps (I tried vkcube-wayland but it crashes)?

The first thing I’m noticing when using the mouse as a framerate test is I see one out of ~3 frames skipped. I have a hunch the mouse is not HW composited but this could easily be a mouse input frequency issue too and I wouldn’t notice. Dragging windows is much slower than moving the mouse.

Environment:

  • kwin.x86_64 6.1.4-1.fc40 (everything started by sddm)
  • nvidia 550.40.71 driver on a 3070
  • added nvidia_drm modeset=1 to the kernel module parameters
1 Like

To debug yes, but to profile or test, a separate machine is not needed these days you can just kwin_wayland --replace (QtWayland 6.6 Brings Robustness Through Compositor Handoffs – David Edmundson's Web Log) and kwin_wayland is in userspace.

Could someone point me to some instructions for minimally launching kwin_wayland and some common and simple test apps

Any app can do the trick. kwin_wayland dolphin will launch kwin_wayland nested.

(I tried vkcube-wayland but it crashes)?

vkcube-wayland crashes is most likely due to vulkan driver issue in Nivida driver (this is not the latest one).

KWin/Debugging - KDE Community Wiki can alsoe be useful.

The first thing I’m noticing when using the mouse as a framerate test is I see one out of ~3 frames skipped. I have a hunch the mouse is not HW composited but this could easily be a mouse input frequency issue too and I wouldn’t notice. Dragging windows is much slower than moving the mouse.

Hardware cursor might be disable on your HW/driver. Would need to check code.
You should be able force it be hardware accelerated. I don’t remember how the env variable is called.

Thanks! I have set up a dev machine for this but am having trouble runing kwin_wayland directly there. Logging in with sddm takes ages the first time (~a few minutes and I’d thought it had hung) but does start kwin_wayland eventually. The next login was quite quick.

pstree:
        │         ├─kwin_wayland_wr─┬─kwin_wayland─┬─Xwayland
        │         │                 │              ├─maliit-keyboard───11*[{maliit-keyboard}]
        │         │                 │              └─9*[{kwin_wayland}]
        │         │                 └─{kwin_wayland_wr}

launched with:
/usr/bin/kwin_wayland --wayland-fd 7 --socket wayland-0 --xwayland-fd 8 --xwayland-fd 9 --xwayland-display :0 --xwayland-xauthority /run/user/1000/xauth_CZpTmd --xwayland

If instead I boot into runlevel 3 and try running kwin_wayland myself I get the following:

$ sudo modprobe nvidia_drm modeset=1
$ ./build/bin/kwin_wayland --drm dolphin
kwin_core: Failed to activate /org/freedesktop/login1/session/_33 session. Maybe another compositor is running?
Accepting client connections on sockets: QList("wayland-0")
kwin_wayland_drm: failed to open drm device at "/dev/dri/card0"
kwin_wayland_drm: No suitable DRM devices have been found

Same when running kwin_wayland from kwin-wayland-6.0.3.1-2.fc40.x86_64. My user is in the video group but same when running as root with sudo env XDG_RUNTIME_DIR=/tmp ./build/bin/kwin_wayland dolphin. I noticed testDrm and that seems to run and pass:

./build/bin/testDrm
********* Start testing of DrmTest *********
Config: Using QtTest library 6.7.2, Qt 6.7.2 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20240801 (Red Hat 14.2.1-1)), fedora 40
PASS   : DrmTest::initTestCase()
QWARN  : DrmTest::testAmsDetection() kwin_wayland_drm: Failed to create any plane. Falling back to legacy mode on GPU  "/dev/dri/card0"
...
QWARN  : DrmTest::testVrrChange() kwin_wayland_drm: Driver doesn't advertise any formats for this plane. Falling back to XRGB8888 without explicit modifiers
PASS   : DrmTest::testVrrChange()
PASS   : DrmTest::cleanupTestCase()
Totals: 13 passed, 0 failed, 1 skipped, 0 blacklisted, 44ms
********* Finished testing of DrmTest *********

This time using akmod-nvidia.x86_64 3:560.35.03-1.fc40 from @rpmfusion-nonfree-updates rather than the .run file from nvidia dot com. When loading nvidia_drm modeset=1 I’m not seeing any errors from dmesg:

[ 2683.438370] nvidia-nvlink: Nvlink Core is being initialized, major device number 236

[ 2683.440242] nvidia 0000:01:00.0: vgaarb: VGA decodes changed: olddecodes=none,decodes=none:owns=io+mem
[ 2683.640659] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  560.35.03  Fri Aug 16 21:39:15 UTC 2024
[ 2683.742151] nvidia_uvm: module uses symbols nvUvmInterfaceDisableAccessCntr from proprietary module nvidia, inheriting taint.
[ 2683.893789] nvidia-uvm: Loaded the UVM driver, major device number 234.
[ 2683.960984] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  560.35.03  Fri Aug 16 21:21:48 UTC 2024
[ 2683.968186] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[ 2685.673623] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 0
[ 2685.673632] nvidia 0000:01:00.0: vgaarb: deactivate vga console
[ 2685.757645] fbcon: nvidia-drmdrmfb (fb0) is primary device
[ 2685.802303] Console: switching to colour frame buffer device 240x67
[ 2685.819856] nvidia 0000:01:00.0: [drm] fb0: nvidia-drmdrmfb frame buffer device

I found some logs from journalctl -b | grep -i 'wayland.*]: '. I think these are just from sddm runs, not my own:

Sep 22 21:27:08 waydev sddm-helper-start-wayland[18097]: "No backend specified, automatically choosing drm\n"
Sep 22 21:27:08 waydev sddm-helper-start-wayland[18097]: "Accepting client connections on sockets: QList(\"wayland-0\")\n"
Sep 22 21:27:09 waydev sddm-helper-start-wayland[18097]: "QSoundEffect(pulseaudio): Error decoding source file:///usr/share/maliit/keyboard2/sounds/key_tick2_quiet.wav\n"
Sep 22 21:27:11 waydev sddm-helper-start-wayland[18097]: "QSGContext::initialize: depth buffer support missing, expect rendering errors\nQSGContext::initialize: stencil buffer support missing, expect rendering errors\n"
Sep 22 21:27:19 waydev sddm-helper-start-wayland[18097]: "kwin_wayland_drm: Presentation failed! Permission denied\n"
Sep 22 21:27:19 waydev sddm-helper-start-wayland[18097]: Stopping... "kwin_wayland"
Sep 22 21:27:20 waydev kwin_wayland[18448]: No backend specified, automatically choosing drm
Sep 22 21:27:21 waydev kwin_wayland_wrapper[18528]: The XKEYBOARD keymap compiler (xkbcomp) reports:
Sep 22 21:27:21 waydev kwin_wayland_wrapper[18528]: > Warning:          Unsupported maximum keycode 708, clipping.
Sep 22 21:27:21 waydev kwin_wayland_wrapper[18528]: >                   X11 cannot support keycodes above 255.
Sep 22 21:27:21 waydev kwin_wayland_wrapper[18528]: Errors from xkbcomp are not fatal to the X server
Sep 22 21:27:29 waydev kwin_wayland[18448]: kwin_wayland_drm: Pageflip timed out! This is a kernel bug
Sep 22 21:27:34 waydev kwin_wayland[18448]: kwin_wayland_drm: Pageflip timed out! This is a kernel bug
...
Sep 22 21:33:08 waydev kwin_wayland[19857]: kf.windowsystem: static bool KX11Extras::mapViewport() may only be used on X11
Sep 22 21:39:29 waydev kwin_wayland[19857]: qt.dbus.integration: QDBusConnection: couldn't handle call to Teardown, no slot matched
Sep 22 21:39:29 waydev kwin_wayland[19857]: qt.dbus.integration: QDBusConnection: couldn't handle call to Teardown, no slot matched
Sep 22 21:39:29 waydev kwin_wayland[19857]: qt.dbus.integration: Could not find slot Krunner1Adaptor::Teardown

Is it possible kwin_wayland falls back to something else when run from sddm? Is there any extra config needed to run it manually?