Turning Ubuntu 12.04 into a professional low-jitter OS.

Ok, here is my low-jitter configured and shaved ubuntu-kernel. A lot of Linux-distros use the standard config, or close. Unfortunately the standard config, is neither specialised for desktop, or server. It is somewhere between, a kind of political standpoint, not siding with either camp. Also debugging is usually left on, and low-latency kernel-variants of ubuntu, still are not agressively tuned towards low os-jitter. What that means is that these distros will perform much poorer on the desktop than it can. And that includes the most popular distro “Ubuntu” which I use. However compiling ones own kernel for it, really gets it to the performance one would want.

Ubuntu is nice, that it is one of the more professional desktop linux distributions. There are linux-distributions with naked women, and constant rap-radio built in, and so I appreciate the more professional variants.

Even if Ubuntu is more professional, Mark Shuttleworth still talks about “lust” on his blog, and one gets the impression that some of the userinterface is influenced by that. That can easily be changed by changing themes and backgrounds ofcourse.

What is important is that the common components are the good ones, and that one has a library to download the common apps, and maybe not so common apps. And I like apt-get.  Ofcourse I haven`t really looked into alternatives, but it seems to work well. And Ubuntu is very popular. Ofcourse if I should critique Ubuntu, it would be to get the lust out, to get the low-jitter in, and I am sure you will understand why. It gives a much more professional desktop, and smoother playback of video and games. Also with Wayland coming up, I am sure, everyone will appreciate low-jitter OpenGL, along with it`s optimized signalpath.

If there should be anything, look at the Ubuntu documentation. Most there should be relevant. Do notice that Ubuntu does not provide support for modified kernels, and it comes with no guarantee.

Kernel debs: Download and doubleclick, and install. (or from terminal (ctrl+alt+t) sudo dpkg -i *lowjitter*)

                           
                           3.5.4-headers                     3.5.4-image

If installing via doubleclick, one also needs to do a “sudo update-grub” in terminal, to update the bootloader. If you have linux installed on several partitions, and you are not installing this on the main partition, you might need to do it first on your current install then your main install.

If you need to install nvidia-driver, see here.
If you want to run minimal, see here. 

Software such as Renoise now plays without interruptions, at 1ms latency, on a 2.5ghz dual-core. (without RT-threads, meaning overall os-jitter is never higher than 1ms .) This on ext4 filesystem, which seems to have the lowest jitter aswell.

To go with this I also recommend, using the lubuntu-desktop. (sudo apt-get install lubuntu-desktop). Also with correct nice-levels, you can run big desktops like KDE, and still have low jitter.

Ofcourse to completely get rid of browser-video jitter, one needs to sync playback to refresh rate.

X-server also needs to be set to high priority, to not be a performance bottleneck:  (which probably belongs in a startup-script somewhere)

sudo schedtool -p 0 -n -20 -N `pgrep X`

Do note that some games require configuration for optimal performance aswell.

For instance doom 3: Download this config file, and install to .doom3/base in your home directory. Also works for prey (.prey/base). Doom 3 is a game that is very sensitive to jitter, and it might be related to that it does 3 passes to OpenGL. So it is an excellent test, to see how the computer performs with regards to jitter. On a core 2 duo/gtx280, it can be made to run perfectly. That is without jitter (frameloss, bad frametiming etc)

NVIDIA specific: Nvidia config for doom3/prey can also be set to quite high resolution: In the nvidia config I set the AA to override, and “8x: 4xSS – 2xMS”, because Doom 3 is an “older” game. Normally I would set this to 2xMS. Anisotropic is also set to 2x, because it makes texturezooming look better (better than higher yes). The loss of textureresolution by 2xaniso only, is madeup by, with 4xSS anyway. For 2xMS only, there should be a slider for  texure LOD, which I use on windows. If those options are not available in your card, just set it to the closest.

With “cat /proc/driver/nvidia/params” we see some settings that can be changed. “sudo gedit /etc/modprobe.d/nvidia-graphics-drivers.conf” creates a file, that changes the obvious stuff. Put this into it, and save.

options nvidia NVreg_EnableMSI=1
options nvidia NVreg_RegisterForACPIEvents=0
options nvidia NVreg_UsePageAttributeTable=1

We can also do some optimizations for a non-compositing window-manager.

Copy and paste into a console. Console pasting can be done, by simply selecting the text, and pressing middle mousebutton, in console.

sudo nvidia-xconfig --no-acpid-socket-path
sudo nvidia-xconfig --no-allow-glx-with-composite
sudo nvidia-xconfig --no-composite
sudo nvidia-xconfig --no-add-argb-glx-visuals
sudo nvidia-xconfig --no-connect-to-acpid
sudo nvidia-xconfig --no-disable-glx-root-clipping
sudo nvidia-xconfig --no-damage-event
sudo nvidia-xconfig --no-enable-acpi-hotkeys
sudo nvidia-xconfig --no-multisample-compatibility
sudo nvidia-xconfig --no-use-events

If you know how to use modelines, here is a modeline for 72.734hz @ 1280×1024. (“minimal psychovisual noise” refresh rate)

“1280×1024″ 142.714 1280 1368 1504 1728 1024 1025 1028 1068 +hsync +vsync

General configuration options: 90hz (lowest jitter) (no high res timers). This kernel also was also hardwired to 1158500nS granularity, which I find to best suit a profile of “natural” with regards to jitter levels in OpenGL. I also enabled tick_skew=1, to further reduce jitter. iommus and misc options are also turned off for minimal jitter, and maximum performance. See also config for other options.

For minimal jitter, run your apps you want low-jitter in, reniced to -20. (doom 3, chromium-browser, wine (needs wine* + winappname*)

If sound is missing in browser after updating to 12.04 you also need to do “rm -rf ~/.pulse”.

Sourcecode from Ubuntu Quantal 3.5.4 Kernel. Edited and configged for “home/pro desktop” with max 16 cpus. It also includes a tweak, and a fix for Fireface UCX soundcard. My local config can also be viewed here.

 :)

Peace Be With You.

update: The bootoption “idle=poll” also improves jitter, and will be in the next version, along with any new developments ofcourse. I am also testing cpuidle.off=1 and rcu_nocbs

Mike Gailbraith also told me kernelthreads were so lightweight, for the most extreme nicing, one could approximately put everything on idle schedule policy, which is preempted by what is run as normal, and X + app on normal pri. - ljtune low-jitter example tuning script, based on this. The perfectionist will ofcourse tweak this to his own taste.

I am also currently compiling the kernel with -fno-defer-pop.