VTE adds ~20 ms of input latency
As part of my effort to reduce input latency in Mutter, I built a latency tester similar to the one described in this post: https://thume.ca/2020/05/20/making-a-latency-tester/. I measured input latency of several terminals and editors and found that VTE-based terminals have about 20 ms higher input latency than non-VTE GTK3 applications and non-VTE terminals.
I did measurements on Fedora 33, Wayland, running GNOME Shell 40.beta on a 1920×1080 144 Hz monitor which showed just the target application.
The test was to run
cat by itself, then repeatedly type and erase the
a letter, and measure the time between sending the a key and the monitor brightness starting to change.
Here are the results. Dots represent individual measurements. Each application has 100 separate measurements (100 a key presses).
VTE-based terminals have consistently higher latency than others, including alacritty (non-GTK terminal) and NeovimGtk (GTK3 application running a neovim
:terminal buffer, which is not VTE-based).
The difference between maximum and minimum measured latency is about 7 ms for most applications, which is close to the expected 1000 / 144 = 6.94 ms if latency was always exactly the same.
I repeated the measurement on my ThinkPad laptop with a 1920×1080 60 Hz screen running Fedora 33 Silverblue with GNOME Shell 3.38 and got a similar input latency difference.
I also did a test running my neovim setup in different terminals and NeovimGtk and once again got similar results.
In conclusion, it seems that VTE is doing something sub-optimally resulting in considerable additional input latency on top of GTK3.