Bug 481374 - Graphics performance in QEMU/KVM guest with virGL is bad on Wayland
Summary: Graphics performance in QEMU/KVM guest with virGL is bad on Wayland
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 5.93.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6, wayland
Depends on:
Blocks:
 
Reported: 2024-02-15 17:14 UTC by Rune
Modified: 2024-06-25 18:23 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
plasma-kwin_wayland service log (3.15 KB, text/x-log)
2024-06-25 13:16 UTC, Marc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rune 2024-02-15 17:14:47 UTC
In a VM using QEMU/KVM, Spice and virGL, graphics performance is very bad with Plasma 6 RC 2 installed. This was tested using Arch Linux - without the KDE-unstable Repo enabled, performance is fine (around 120FPS in glxgears); with the repo enabled and thus Plasma 6 RC 2 installed, graphics performance is very bad (20FPS in glxgears). This is very evident in desktop use, not just with 3D-applications.


STEPS TO REPRODUCE
1. Install an Arch Linux guest in a QEMU/KVM VM
2. Enable virGL for the guest

OBSERVED RESULT
Bad graphics performance

EXPECTED RESULT
Good graphics performance

SOFTWARE/OS VERSIONS
Linux: 6.7.4-arch1-1
KDE Plasma Version: 5.93.0 
KDE Frameworks Version: 5.249.0
Qt Version: 6.7.0
Comment 1 Rune 2024-02-15 17:37:50 UTC
I tried fedora rawhide too - same problem, so this seems to be a problem of some Plasma component, not Qt 6.7
Comment 2 Nate Graham 2024-02-16 20:06:56 UTC
Does it happen on both X11 and Wayland, or only one?
Comment 3 Rune 2024-02-18 09:20:41 UTC
(In reply to Nate Graham from comment #2)
> Does it happen on both X11 and Wayland, or only one?

It happens in wayland only.
Comment 4 Nate Graham 2024-02-20 22:07:38 UTC
Thanks.
Comment 5 Marc 2024-05-23 19:42:03 UTC
I'm seeing something very similar here. I just booted the neon-user-20240523-1335.iso ISO in QEMU (I'm running Ubuntu 22.04 as the host system).

Simply moving the mouse around gives me these messages in the system journal (journalctl | grep libinput):

May 23 18:55:55 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: client bug: event processing lagging behind by 29ms, your system is too slow
May 23 18:55:56 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: client bug: event processing lagging behind by 78ms, your system is too slow
May 23 18:56:01 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: client bug: event processing lagging behind by 28ms, your system is too slow
May 23 18:56:05 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: client bug: event processing lagging behind by 32ms, your system is too slow
May 23 18:56:38 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: client bug: event processing lagging behind by 32ms, your system is too slow
May 23 18:56:38 neon kwin_wayland[1104]: kwin_libinput: Libinput: event2  - VirtualPS/2 VMware VMMouse: WARNING: log rate limit exceeded (5 msgs per 60min). Discarding future messages.

From what I undertand, kwin_libinput isn't able to keep up (dispatch) events fast enough and so libinput complains.

I also have this exact same behaviour on a custom image (yocto based) running plasma mobile.

Another thing to try is `sudo evtest`, select the first mouse (VirtualPS/2 VMware Mouse) and look at the events. The faster the mouse moves the 'jerkier' it gets. CPU usage for the kwin_wayland process also goes up substantially (~12%).

Note: doesn't happen when running on mutter, with the same QEMU setup.

kinfo:
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.0
Kernel Version: 6.5.0-35-generic (64-bit)
Graphics Platform: Wayland
Processors: 2 × AMD Ryzen 9 7900 12-Core Processor
Memory: 7.7 GiB of RAM
Graphics Processor: virgl
Comment 6 Zamundaaa 2024-06-25 12:54:32 UTC
Please attach the full output of
> journalctl --user-unit plasma-kwin_wayland --boot 0
Comment 7 Marc 2024-06-25 13:16:02 UTC
Created attachment 170960 [details]
plasma-kwin_wayland service log

There you go.
Comment 8 Zamundaaa 2024-06-25 18:04:10 UTC
Okay, KWin is using legacy modesetting, with XRGB8888 as the buffer format. I can't think of any reason this would be slow, without Xorg also being slow
Comment 9 Marc 2024-06-25 18:23:37 UTC
(In reply to Zamundaaa from comment #8)
> Okay, KWin is using legacy modesetting, with XRGB8888 as the buffer format.
> I can't think of any reason this would be slow, without Xorg also being slow

Note that if my mouse cursor is _not_ on the QEMU window, the system doesn't experience slowdowns. It's only when I move the mouse that everything seems to slow down. For example, navigating the 'start' menu is very jerky in the VM but works fine on bare metal... very strange.

My QEMU configuration:

/usr/local/bin/qemu-system-x86_64 \
    -enable-kvm \
    -cpu host \
    -drive if=pflash,format=raw,unit=0,readonly=on,file=/usr/share/ovmf/OVMF.fd \
    -drive file=$image_file,if=virtio,format=raw \
    -device virtio-net-pci,netdev=net0 \
    -device virtio-rng-pci \
    -device virtio-vga-gl \
    -display gtk,gl=on \
    -m 8G,maxmem=16G \
    -machine q35,accel=kvm \
    -netdev user,id=net0,hostfwd=tcp::2222-:22,"${PORT_FWDS}" \
    -boot d \
    -drive file=/home/marc/Downloads/neon-user-20240523-1335.iso,media=cdrom,readonly=on \
    -smp 2

QEMU version: 9.0.0