Hacker News new | ask | show | jobs
by prhn 16 days ago
Awesome article.

I switched my daily driver / gaming rig to Fedora a few months back.

Everything seems snappier compared to Windows, but not sure if it’s in my head, and I’ve been very curious about gaming input latency. This helps answer some questions.

I recently switched to hyprland and I’m very interested how that fits in these results. hyprland uses Wayland so I hope the author might revisit now that hyprland is gaining in popularity.

I’ve considered using gamescope to hopefully get in front of some of these concerns, but I’m on nvidia and there is some discussion about it not working well there.

Now the author's got me thinking about gaming-optimized kernels, which I did not realize was a thing.

I play competitive fighting games so input latency is a huge concern. Would love to hear from anyone else who’s been down this path.

4 comments

With the exception of XWayland, all of the tests had input latencies within a very small range. No human could tell them apart by those latency differences alone. I would be amazed if someone could notice the 3ms difference jump to XWayland.

The difference could be much larger on a slower monitor. However the differences between Wayland and X11 as protocols is negligible. XWayland as an implementation looks to have a limitation.

The context here is the article's author is a twitchy FPS player, those extra 3ms are something that community agonizes over. I appreciated how much effort was put into controlling the variables in this test. There's a whole lot of witchcraft associated with these kinds of efforts and he sat down and did the measurements and got real numbers. My hat is off to OP.
ping is going to dominate over 3ms in pretty much every situation.

And the non-xwayland numbers are all within a single ms of each other.

---

Not to undermine the measurements of the author (agree with you, it's a cool effort), but my read is that this was basically proof that it doesn't matter.

In the context of competitive online games, ping is going to be ~10-60ms, depending on your connection to the particular server you're playing on, and not particularly noisy (and that's a roundtrip time. Client-Server latency would be 5-30ms). In order for one value to "dominate over" another in an adversarial context, the variance of the former must be much greater than the base rate of the latter.

Imagine a game that's just a pistol duel. When the kerchief hits the ground, players press a button, first person to press the button wins.

In an ideal world, with no delay whatsover, the probability P(A) of player A shooting no later than player B is 100 (because both players shoot at exactly the same time). If we add 5 ms of delay to player A, then P(A) = 0 (he will always lose). If then we add 50 ms of network latency to both players, P(A) = 0 still, because 55 > 50. If we instead make that 50ms delay 50ms +- 10ms (ignoring normal distribution for the moment, pretending every value in that range is equally likely), there's a 25% chance of player A experiencing an unwinnable delay (any network delay value > 55ms results in a value greater than player B's max of 60ms), resulting in a probability of P(A) = 75% * 50* = 38%.

If we make the network delay 50ms +- 5ms, then P(A) drops to 25%.

You can genuinely feel just a few milliseconds of input latency with a mouse, it disconnects looking around with your physical actions. It's the same way you can feel the difference between low and high refresh rate monitors, even though you can't really count the frames themselves
It doesn't matter. Whether you have a ping of 40 or a ping of 300, 3ms is 3ms and will mean you win a little less often.

The saying we have in bike racing marginal gains is "leave no stone unturned, but turn over the big ones first"

So sure, first make sure your internet connection is solid. Then make sure your hardware and game settings are optimizing FPS to a reasonable point of diminishing returns.

Then make sure you don't use XWayland

Lag compensation means ping is an entirely different phenomena with different effects from input latency. While details vary between games for the most part pieces of the game like hitting enemies (but not being hit yourself) and moving your own character are operating on a local simulation with zero latency from ping.

There are weird consequences of this, someone can shoot you after you duck behind a wall because you hadn't yet in their version of the game. An enemy moving left right repeatedly is likely vibrating in your version of the game faster than the rules of the game would otherwise allow. Etc. Ping matters, but it's not comparable to input latency. Input latency really does mean that you can click at the right time and miss your enemy. It really does delay how fast your camera spins when you move your mouse. Etc.

Latency is additive, it doesn't matter how much latency you already have, any extra on top always still hurts.
Since 4ms is already about at the limit of my input latency tolerance for snappiness, I came to a different conclusion: "Wayland VRR" is the only tolerable Wayland option.
I have no idea about gaming but in the music world you start noticing latency when it is above 5ms and the difference between 5 and 8ms is tangible. For the most part anything under 10ms is workable and you will quickly adapt as long as the latency is constant. Under 10ms of latency is a level of latency we are used to dealing with, if you are playing guitar and your amp is 10 feet from you, you have ~9ms of latency. Our brains are pretty good at adapting to these short latencies as long as they are predictable.

The visual latency on gaming could be different but I suspect not, I think it is more an issue that some people fixate on the latency, others just accept and adapt to it. Games do have more possible sources of latency, visual, audio and io, and if these can all be different that can be difficult; years ago I had an issue with this and midi, that one really threw me off. Games may also not model the physics of sound? does sound travel slower than light in games? That could worsen the problem since sound does travel slower in real life and we are used to that, we expect it.

It's very valuable data that everything is so close. It means that most folks can simply ignore it. On the other hand the inferior nature of xwayland well explains the bad rep for wayland latency.

Consider also that people neither run the latest thing nor the fastest software and remember potholes long after they are filled. EG it wasn't that long ago that wine was running on xwayland almost exclusively for instance and the majority of popular titles run via wine.

Also the author is testing a game engine.

It’s possible that Gnome/KDE/whatever has wildly different latencies on X11 vs Wayland.

I’d be interested in seeing that test.

But it’s great to know the difference is so small here, which is what I’d expect.

I can tell down to about a 3ms difference in lag. Actually even down to 1ms, it's not all its cracked up to be, lemme tell you.
You think you can and will inevitably fail to do it in blind testing.
While reaction response is around 100ms, for predictive movements, ie press a button exactly when a bouncing ball hits the ground, average people can get down into 5-7ms of timing accuracy[1]. Trained people can get below 4ms in certain cases.

Of course, the brain adapts. I played an online shooter at >100 FPS using my 144 Hz monitor (when that was the best). I visited a buddy who's PC could only muster 30-40 FPS, and he asked me to show me how I played, since he struggled.

I sucked so bad due to the extra input lag. Felt like my character was running in a pool of molasses. But after about 15-20 minutes my body adapted, and my performance started increasing and my hits started connecting more reliably. I got to about 90% of my regular performance after 30 or so minutes.

So while one could tell back to back, one could also compensate. But at some point the extra input lag will matter, and will get you killed or make you miss that shot. Hence why I could only get up to ~90% of my normal performance on my buddy's PC.

[1]: https://jov.arvojournals.org/article.aspx?articleid=2213289

Well, of course people can generally see the difference between 30 and 100+ FPS but it is much bigger delay than 1ms OP claimed they can distinguish.
As noted in the paper I linked to, display framerate did not affect the timing precision of their participants, from 120Hz down to 24Hz. So it's more about feeling it rather than seeing it.

If you can be accurate to below 5ms, an additional millisecond of input lag makes a big difference.

It directly impacts performance when playing twitch fps games, any input lag causes measurable difference in score. This is before people even notice it happening.
I would love to see some research confirming that 1ms of addition latency that OP claims to be able to perceive impact performance of twitchy FPS players.
I can tell, doesn't mean I can react usually.

Adapting is doable, but after years of rhythm games, yeah, no.

As far as I'm aware, you get marginal FPS gains switching kernels. It helps some. It's just a matter of whether the effort is worth it to you. The main change is the scheduler: rather than trying to evenly distribute CPU time to processes, it will prioritize bursty processes.

I've been a fan of Hyprland for gaming so far. Much more configurable for things like VRR/tearing and other precise tweaks via Gamescope than when I was on AwesomeWM with X11. Been especially nice having Lua for configuration, which finally feels very familiar with my AwesomeWM roots.

I moved to OpenSuse and have the same experience/opinion. The only caveat I had in Wayland is Game Streaming. Sunshine/Moonlight work but the input lag is noticeable and there are artifacts in the game. I go back and forth between X11 and Wayland just because X11 better for game streaming but in time I'm sure I'll go full-time into Wayland.
I've set up sunshine + moonlight on Fedora KDE Wayland, and I've played remotely from a different country with unnoticeable input lag (using a gamepad, playing Cyberpunk). The whole thing is even behind WireGuard.

I have very fast internet on both sides, both fiber to the home, with only the tablet running moonlight being on WiFi.

When you say game streaming, is this the steam streaming stack?
sunshine + moonlight is the streaming stack. Steam's one is pretty bad, and still only works in X11.
I use gamescope on a separate TTY that directly launches either steam or heroic launcher. I find this works exceptionally well. No window manager needed as you are playing a game full screen anyway. It fixed some other things like HDR too but at a loss of the volume and brightness keys no longer working.
That sounds very interesting, do you have any links or references on how you set it up?
Don't know about gamescope, but the core of my own wine launch script is basically this:

  if [ -z "$DISPLAY" ]; then
    /usr/bin/startx /usr/bin/dbus-launch "$(readlink -f $0)" "$1" -- -layout singleLayout
  fi
  pw-cli i || (pipewire & sleep .5 ;\
               pipewire-media-session &\
               pipewire-pulse &)
  cd "$DIR"
  exec unshare -rcn $ENGINE "$IMAGE" $ARGS
and the rest of the script is about setting up the environment for the game: setting all the parameters used above, exporting the correct WINEPREFIX, mounting .iso's if required, etc.
I just used an llm to configure bashrc at login to offer a menu to fire it off. Either steam heroic or CLI (logging in as a separate game user)

Gamescope replaces X or Wayland so you just run it and then the app you want it to open