variable key (and mouse?) lag - Xubuntu 20.04
I'm running Xubuntu 20.04 on a Lenovo Thinkpad Yoga X1 1st gen. This is Xserver 1.20.9 and Linux kernel 5.4.0. However, the problem has been around for a long time - I was running Xubuntu 18.04.01, it seemed to get worse when I upgraded to 18.04.05, and worse again when I upgraded to 20.04.
The observed problem is that there is a variable lag between pressing a key and the application (even simple Xlib/Xt applications such as xterm and emacs) seeing the key. Impressionistically, about 10-20% of keypresses suffer noticeable delays, and occasionally it is as much as a second, making touch-typing hard. The upshot is that my typing experience is worse than it was in 1987 under X10 !
This is a quite widely reported problem according to google, with no solutions in sight. (There are many other lag problems with identifiable causes.)
So far I have determined that the lag happens before the X server assigns a timestamp to the event, because the difference between real time on application event receipt and event timestamp is consistent to within a millisecond or two.
However, if I run evtest along with the application, the delay is seen: the application receives the event usually about 0.7ms after evtest sees it, but sometimes after much longer, up to a second. I have been unable to reproduce this - there may have been an error in my timestamp reading.
Sometimes (I don't have this in a trace) it seems that events are queued up and delivered in a burst after the delay - somehow, particularly with backspace, the backspacing happens all at once after a short delay.
The machine is not running anything intensive (just a couple of browers), and there are no messages in dmesg, syslog, or Xorg.0.log indicating anything that might be interfering.
I think the problem may also appear with mouse button events, but this is harder to determine.
I should be grateful for advice on what to investigate next. I don't really want to have to build and debug Xserver locally, but the problem is now bad enough that I will if that's what's needed.