Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve input latency #673
First, for background, please see https://danluu.com/term-latency/
In the case of Alacritty, we have a worst-case latency (assuming reasonable draw times) of 3 VBLANK intervals. Here's the scenario:
In total, that's
This can be resolved by moving the rendering to a separate thread. Certain windowing APIs require input processing to occur on the main thread, so input processing must stay in place. In the same scenario as described above, we can reduce the worst case to 2 VBLANK intervals. With input processing on its own thread, it no longer needs to wait for
I wrote this on the /r/rust thread and someone asked me to file a ticket but I thought a comment in the existing ticket may be better, so here it is.
On my setup there's noticeable input lag in Alacritty, compared to other terminals like st and konsole. I don't know how to measure it and I'm happy to help with getting some numbers/debugging/profiling etc.
Here's how I feel the lag: when I keep a key pressed so that it repeats (e.g. arrow keys or hjkl in vim), after I stop pressing the key the key repeats one or more times, whereas in other terminals key repeat immediately stops. This makes alacritty feel like it's coming behind my actual key presses (as if key press events are waiting to be handled but alacritty is not fast enough, so even after I stop pressing it handles old key press events).
My key repeat settings: 260ms repeat delay and repeat speed of 55 key strokes per second (
Secondly, when typing I notice that it takes slightly more time in alacritty to see the letters appear. But this isn't as serious issue as and I'd probably get used to this if the other issue is fixed.
The problem with performance and latency problems is that everything is fast enough until you see something faster (e.g. 30 FPS in games was acceptable years ago, now anything below 60 FPS seems laggy), so it's hard to talk about these issues. Let me know if I can provide anything to diagnose the problem.