When it comes to gaming, Linux is still a bit behind Windows. Don’t get me wrong; it has come a very long way in the space of a decade, turning the OS from a productivity-only distro to a serious competitor in the gaming scene. But there are a handful of problems that prevent people from making the jump.
One of them is with KDE Plasma. On its own, KDE Plasma is a fantastic desktop environment that makes Linux more accessible than it has ever been. But gamers have noticed a strange mouse input delay with KDE Plasma, and nobody was really sure what was causing it. Fortunately, someone performed a deep dive to see what the problem was and ended up finding not one problem, but three.
Jakub Okoński sets out to solve the problem of mouse input latency in KDE Plasma
And does a lot of experimentation and measurements along the way
The story starts when one Jakub Okoński noticed that using the cursor on KDE felt strange compared to Windows. He noted that changing some settings would sometimes make the mouse feel ‘floaty’ and weird. So, as all good tinkerers do, he decided to get to work solving this weird problem.
To start, he set up the hardware:
Measurements were done on two computers: a desktop and a laptop. They each have an Ada-generation RTX card and a Zen 4 CPU. I used virtually the same NixOS config on both, along with an up-to-date Windows 11 install on each. They were connected to the same display for most of the tests: an LG C1 at 120 Hz over HDMI. […] App settings were selected to avoid hardware bottlenecks. My goal was to easily hit 120 FPS on a 120 Hz output and test for any queueing effects in the software stack.
Next, he used a Teensy microcontroller that acted as a USB mouse and would send inputs to the PC. It was also attached to a light sensor that was pressed against the screen. He then booted up one of three games: Doom Eternal, Borderlands 3, and Hades 2. He then set it up so that the mouse would perform an action in-game and record the outcome using the light sensor. For Doom and Borderlands, this involved shooting a gun in a dark room and grabbing the muzzle flash, and for Hades, it was performing a skill the light reader could ‘see’.
Sure enough, he noted that Linux’s KDE Plasma processed clicks 4ms slower than Windows. That doesn’t sound huge on paper, but in a competitive scene, 4ms could mean the difference between victory and defeat. So he got to work finding the cause.
Related
I switched from GNOME to KDE Plasma 6.6 and it fixed all my complaints about the Linux desktop
It’s time to move on from GNOME
KDE Plasma’s delay comes from three different sources
And they all add up to one big issue

Okoński rolled up his sleeves and began digging through KWin for the problem. He ended up with three; the first was a timer that wasn’t very precise. KWin uses a tool that automatically rounds any timer delay up to the nearest millisecond. That sounds like it wouldn’t make a dent, but when you’re rendering a game, it can make a noticeable impact, especially on faster monitors. To solve this, Okoński built his own replacement timer, getting the delay down to about 51 millionths of a second in a worst-case scenario. It wasn’t completely gone, but it was essentially ‘fixed’.
Next up was a safety margin Kwin used as a buffer before sending out a frame to the display. This was set up just in case processing took a little longer than the OS expected. However, the safety margin was a little too protective, as someone had set it to add 1.5 ms as a precaution. Okoński noticed that this was set experimentally, and not via rigorous testing, so he grabbed some new Nvidia drivers and noticed he could crank the delay down to 0.3 ms on a 120Hz screen.
Finally, he noticed that KWin was still a little outdated when it came to GPU expectations. KWin was programmed to believe that a GPU would take 2 milliseconds to compose a frame, but Okoński noted he could get away with setting this below 1ms with modern hardware.
All of these made a noticeable delay in inputs, especially when there was a background app taking up resources. Near the start of the tests, he noticed that even leaving a coding environment open in the background while running his tests caused a bit more delay. This was because applications were shoving each other out of the current frame and forcing them to wait for another, which sometimes added up to 8ms of delay in really bad scenarios.
Related
SteamOS tricked me into switching to Linux, and I’m not going back
Sneaking its way into my heart
Jakub Okoński begins working on a fix
It’s not quite at Windows speeds yet, but it’s getting there.
Now that he knew what was causing all these problems, he could code up a patch and re-run the tests. He managed to save about 1-1.2ms in delay, bringing the gap between Windows and Linux by around 3ms.
It’s not the home-run fix that will cause Linux to catch up with Windows, but hopefully, with a little bit of work, the KDE community as a whole can help Okoński out and get that number as close to 0 as humanly possible. Until then, Linux gamers will have to hold on tight for the fix to arrive.
Related
Linux gaming is getting faster because Windows APIs are becoming Linux kernel features
As time goes on, fewer games than ever are unplayable on Linux


