Debugging Input Lag on Ubuntu 17.10

linux, ubuntu

I recently had an issue with very slight display lag on my Ubuntu 17.10 desktop, which had a very interesting fix.

For context, I have an i5-4XXX series desktop with a nVidia GTX 970, and two 1080p Samsung BX24440 ‘SyncMaster’ monitors connected via DVI.

A few nights ago, I turned off my computer to move it so that I could switch to a new desk setup. By doing so, I allowed my OS to apply a few kernel updates that require a reboot to be fully applied.

After rebooting, my machine had a noticeable display lag, on everything from mouse movement to hardware-accelerated video playback on YouTube.

My first thought was that by updating my kernel I had inadvertently applied some update that did not agree with my system. In my experience, this is very, very rare on modern Linux distributions, especially Ubuntu, but with the recent Spectre / Meltdown patches, I figured it was still possible.

So, I began rolling back each package that had been updated, one by one. An hour or so later, and after an hour of cursing myself for not just installing NixOS already, I figured I had hit a dead end.

So I dove deeper. Two things were apparent: During the period of lag, Xorg was using about 30% of a core, which is very high for Xorg.

Inspecting the Xorg log in /var/log/Xorg.0.log revealed something curious. Hundreds of messages blocks like this;

1
2
3
4
[    12.049] (--) NVIDIA(GPU-0): Samsung SMBX2440 (DFP-4): connected
[    12.049] (--) NVIDIA(GPU-0): Samsung SMBX2440 (DFP-4): Internal TMDS
[    12.049] (--) NVIDIA(GPU-0): Samsung SMBX2440 (DFP-4): 330.0 MHz maximum pixel clock
[    12.049] (--) NVIDIA(GPU-0):

So what was the solution?

Tighten my DVI cable.

As far as I can tell, when I moved my computer, the DVI connection between my GPU and my monitor became ever so slightly loose, in such a way that the GPU was detecting the monitor to become disconnected and reconnected about once per second. Even though there was no perceptible monitor flicker or “disconnected” messages, the process of disconnecting and reconnecting appears to have been consuming enough resources to delay frame rendering slightly every time it happened.

So, lesson for you - if you have display lag on a Linux system that you just can’t debug, maybe you just need to tighten your monitor connections.


I'm looking for better ways to build software businesses. Find out if I find something.