[SOLVED] Is a realtime kernel needed?

Optimize your system for ultimate performance.

Moderators: khz, MattKingUSA

Brynildsen
Establlshed Member
Posts: 23
Joined: Tue Nov 28, 2017 12:30 pm

[SOLVED] Is a realtime kernel needed?

Postby Brynildsen » Wed Dec 20, 2017 2:19 am

I have until now always used standard kernels, and it have (and still does) served me well for making music. Maybe because I have a very fast cpu and a lot of ram.. dunno.. It's a topic I really don't know much about, so here it goes..:

1. What are the main differences in having a realtime kernel installed, compared to having set realtime priorities for audio in /etc/security/limits.d/99-audio.conf

2. Do you use it all the time?, or do you load different ones at boot ( in case you also use your pc for regular things, work etc..), and how do you do it if so..?

3. Are there situatons where realtime kernels aren't necessary (overkill), or maybe could create problems..?
Last edited by Brynildsen on Wed Dec 20, 2017 12:15 pm, edited 1 time in total.
"Arch/i3-wm/Bitwig/Renoise/Guitarix/Airwave/a couple of winVST's"
"i7-6700K 4ghz, gtx910ti, 16gb ram" + "X201s-i7-640LM 2.13ghz, 8gb ram"
"Presonus 22vsl + Scarlett 2i2 2.gen."

superprick
Establlshed Member
Posts: 111
Joined: Fri Dec 28, 2012 10:47 pm

Re: Is a realtime kernel needed?

Postby superprick » Wed Dec 20, 2017 3:46 am

1. as i understand realtime kernal gives priority to interups also I am probably wrong
2. I use the low latency kernal. RT is not welcome here. I do a lot of video editing and the nvidia drivers are not easy to manager with RT
3 See number 2

all in all if you are running bunt/variant. install the low latency kernal and forget about it. I use a lot of win/vst and have noticed that it does help compared to the standard kernal. even on my 4 socket 48 core 96 thread workstation. (Yea i know but i upgraded a clients lab machines and they tossed the 3 year old machines. :D :D :D ) i have xruns with the standard kernal and say 60 win/vst

hope this helps

dufflespank
Establlshed Member
Posts: 6
Joined: Sun Dec 17, 2017 7:02 pm

Re: Is a realtime kernel needed?

Postby dufflespank » Wed Dec 20, 2017 4:17 am

from my recent experience: I was able to tune settings on my standard kernel until the xruns were rare, however I would still get an xrun once every 20 minutes or so. If you can live with that then go for it, but personally I don't like the idea of having a recording just randomly get nuked by a drop out.

If you are running Ubuntu, just do "sudo apt install linux-lowlatency". After it is done installing, reboot the machine and hold shift (or escape) to drop into the grub boot menu. There, you will be able to select which kernel to load. Keep in mind that running a different kernel is largely transparent to the user, it will just be like any other desktop session... with the added benefit of no more xruns :)

User avatar
CrocoDuck
Establlshed Member
Posts: 778
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Is a realtime kernel needed?

Postby CrocoDuck » Wed Dec 20, 2017 5:05 am

Brynildsen wrote:I have until now always used standard kernels, and it have (and still does) served me well for making music. Maybe because I have a very fast cpu and a lot of ram.. dunno.. It's a topic I really don't know much about, so here it goes..:


If your performances are good with a standard kernel, then you don't need anything fancier :D This is not entirely surprising nowadays.

Brynildsen wrote:1. What are the main differences in having a realtime kernel installed, compared to having set realtime priorities for audio in /etc/security/limits.d/99-audio.conf


RT kernels have a different preemption model. You can read about it here. Audio is a hard real-time task, as audio programs have to calculate the output buffers by the time a new buffer is served. That is a deterministic time given by buffer size and sample rate. A real-time kernel is better suited for real-time tasks, so it can help for audio. It is about how the processes are queued for execution by the OS.

Brynildsen wrote:2. Do you use it all the time?, or do you load different ones at boot ( in case you also use your pc for regular things, work etc..), and how do you do it if so..?


I have a RT kernel installed, but I often just boot the normal one. I use the RT only when I want to push to the lowest latencies. I have a feeling the RT kernel drains my laptop batteries faster, but I am not quite sure about it.

Brynildsen wrote:3. Are there situatons where realtime kernels aren't necessary (overkill), or maybe could create problems..?


It depends on the application the machine is intended to serve. For servers, RT kernels are a big NO GO, as servers need to take care of multiple processes at the same time without the RT tasks becoming a bottleneck for the others. For normal everyday use I am not sure there are big cons, but I prefer to go with the standard one as it is more supported (for example, ready to install VirtualBox kernel modules, etc...). Nvidia drivers can be installed on RT kernels, just a bit more complicated.
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

asbak
Establlshed Member
Posts: 583
Joined: Thu Sep 11, 2014 3:04 pm

Re: Is a realtime kernel needed?

Postby asbak » Wed Dec 20, 2017 7:20 am

My general layman's rule of thumb is that with a standard kernel (and jack running on a too low priority etc) a soundcard will typically produce too many xruns at low latency settings (when set to below 10ms or so). If you don't play live instruments (virtual synth, guitar fx etc) it is possibly not that important to use low latency audio settings. If you play live instruments or you are doing FX processing for a live show etc then it would be ridiculous to have to deal with massive delays.

That leaves options between a preempt or a rt kernel. As others have already mentioned rt kernels come with their own sets of issues.

I couldn't notice much, if any, difference between rt & preempt kernels with regards to the amount of xruns produced so opted for the preempt kernel. It's in general everyday use on my laptop and works fine for both audio and general computing purposes.

In my opinion the rt kernel is best avoided unless you know exactly what you are doing and have specific reasons to require it. (There are such usage cases, for example in industrial automation control systems where it is essential to use a rt kernel.) For audio / music production, I would - and do - use the preempt kernel.

Jack Winter
Establlshed Member
Posts: 152
Joined: Sun May 28, 2017 3:52 pm

Re: Is a realtime kernel needed?

Postby Jack Winter » Wed Dec 20, 2017 8:30 am

Brynildsen wrote:I have until now always used standard kernels, and it have (and still does) served me well for making music. Maybe because I have a very fast cpu and a lot of ram.. dunno.. It's a topic I really don't know much about, so here it goes..:

1. What are the main differences in having a realtime kernel installed, compared to having set realtime priorities for audio in /etc/security/limits.d/99-audio.conf

2. Do you use it all the time?, or do you load different ones at boot ( in case you also use your pc for regular things, work etc..), and how do you do it if so..?

3. Are there situatons where realtime kernels aren't necessary (overkill), or maybe could create problems..?


Let me see if I can add my musings in a coherent manner ;)

There are several types of kernels with different scheduling models, both low latency and realtime kernels will preempt running programs to let other programs run. The big difference between the above two being that the realtime kernel tries to make the kernel itself preemptable too, thus leading to lower delays in kernel scheduling, which might allow you to run your audio at lower buffer sizes (read lower latency) without xruns. Note that the kernel might not be the only problem causing xruns at lower latency, there are other issues that might cause xruns, like nividia drivers, some wifi drivers, bios code, etc.

Regarding point 1, realtime priviliges are completely unrelated to lowlatency vs realtime kernel, and you'd be well adviced to take care of point 1 no matter what kind of kernel you use if you want low latency audio.

2. Yes I use it all the time on my audio machines, and I haven't noticed any real drawbacks with it.

3. As noted, it can make it more problematic to use nvidia, vbox and other external kernel modules, but IMO this is something your distribution ought to take care of for you. It's also not suitable for most server applications, as reducing kernel scheduling latency normally leads to lower throughput. It's simply a trade off inherent in the design.

My advice is the following. For audio work use at a minimum a lowlatency kernel, take care of limits.conf and also important is to make sure that the kernel exports interrupt handlers as threads and to set a high priority for the interrupt handling your soundcard (something like priority 95 is good here). Then run jack or your audio threads somewhere around priority 80). This should be good for achieving buffersizes of 128-256 at 2-3 periods. Which might be all you need for recording and mixing. Personally I mostly run my system at 1024/2-3 (depending on what soundcard I'm using).

If you need lower latency than this gives (say for monitoring live input through FX), then you probably have to install a realtime kernel.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, 2 x WA-412, ADL-600, Tegeler TRC, and too much other stuff to list 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

Brynildsen
Establlshed Member
Posts: 23
Joined: Tue Nov 28, 2017 12:30 pm

Re: Is a realtime kernel needed?

Postby Brynildsen » Wed Dec 20, 2017 12:06 pm

This is a lot of great answers and explanations.. Thanks.. :)

I always thought rt-kernels and lowlatency-kernels was the same thing.

I mostly record guitars and have always used effects processors and direct monitoring, but I am trying to make a light transportable setup also with a laptop and a sound interface only, and use plugins/standalone applications to generate the sound instead. The laptop of course is not same specs as my desktop and I do get "the magic single xrun" showing up once in a while, out of no where. Like every 10-15 min, even though the settings seems to work pretty good for monitoring without distracting latency.

I am definitely going to try other kernels also now. I just wasn't sure how it worked, and if you could have them all installed at once and easily boot and use the one you want instead of dualbooting other distros for music production.

I'll mark SOLVED, but feel free to add other tips and tricks if you feel something is missing.
Last edited by Brynildsen on Wed Dec 20, 2017 12:29 pm, edited 1 time in total.
"Arch/i3-wm/Bitwig/Renoise/Guitarix/Airwave/a couple of winVST's"
"i7-6700K 4ghz, gtx910ti, 16gb ram" + "X201s-i7-640LM 2.13ghz, 8gb ram"
"Presonus 22vsl + Scarlett 2i2 2.gen."

Jack Winter
Establlshed Member
Posts: 152
Joined: Sun May 28, 2017 3:52 pm

Re: Is a realtime kernel needed?

Postby Jack Winter » Wed Dec 20, 2017 12:24 pm

Note that laptops are notoriously difficult to get really low latency on... Many of them have code running out of bios and no way of disabling it. But the only way to know what kind of xrun free latency you can get is to try and run for a long time in order to validate the result. But if you are going for the lowest latency, then IME a realtime kernel will definitely help. You might also have to disable certain hardware drivers, wifi being a common case.

IMO if you can get it down to around 10-15ms roundtrip latency without xruns you ought to be good (different people have different preferences for when latency starts becoming noticeable and a bother). One thing to keep in mind, is that with usb there is quite a lot of additional latency incurred over the usb protocol, that is to say that there is additional latency to the one given by samplerate, buffersize, and period settings. There are programs to measure this by connecting a loopback cable between a soundcard output and input.

You can most certainly have several kernels installed at the same time, you'd need to add them to a boot manager such as grub, refind, etc.
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, 2 x WA-412, ADL-600, Tegeler TRC, and too much other stuff to list 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

asbak
Establlshed Member
Posts: 583
Joined: Thu Sep 11, 2014 3:04 pm

Re: Is a realtime kernel needed?

Postby asbak » Wed Dec 20, 2017 9:23 pm

Brynildsen wrote:The laptop of course is not same specs as my desktop and I do get "the magic single xrun" showing up once in a while, out of no where. Like every 10-15 min, even though the settings seems to work pretty good for monitoring without distracting latency.


Run something like iotop & htop, monitor your system for disk & cpu spikes and note what processes are causing them. Some of those may be xrun culprits.

Check what cronjobs / housekeeping processes are scheduled to run, how often, when etc on your OS. These may very well also lead to CPU & IO spikes causing occasional xruns.

WIFI driver..... another potential notorious source of xruns.

Webbrowsers... ditto.

On one of my systems Nouveau nVidia drivers caused excessive xruns. Perhaps other users had better experiences with them but they didn't perform well for me. The closed source nVidia drivers performed much better.

The choice of soundcard also plays a big role. Some are capable of much lower latencies than others. The *Behringer UMC models are very affordable, sound OK and operate at low'ish latencies in Linux. (*But do your own research before buying any soundcard whether that specific model is known to be working in Linux.)

Taika-Kim
Establlshed Member
Posts: 13
Joined: Mon Sep 07, 2015 3:16 pm

Re: [SOLVED] Is a realtime kernel needed?

Postby Taika-Kim » Tue Mar 13, 2018 6:08 am

Anybody running a low latency kernel on Ubuntu 17.10 here? I installed it, and system response like mouse and keyboard became ridiculously slow, keypresses were mostly missed, etc. Otoh I get already under 3ms latency without xruns with stock Ubuntu straight out of the box, so I'm not sure what good anything faster would do. I was under the impression that most of the functionality of the low latency kernel is nowadays embedded in the regular kernel.

basstrombone
Establlshed Member
Posts: 20
Joined: Sun Mar 18, 2018 11:39 pm
Location: Paraíba, PB Brasil
Contact:

Re: [SOLVED] Is a realtime kernel needed?

Postby basstrombone » Wed Apr 11, 2018 1:12 am

Taika-Kim wrote:Anybody running a low latency kernel on Ubuntu 17.10 here? I installed it, and system response like mouse and keyboard became ridiculously slow, keypresses were mostly missed, etc. Otoh I get already under 3ms latency without xruns with stock Ubuntu straight out of the box, so I'm not sure what good anything faster would do. I was under the impression that most of the functionality of the low latency kernel is nowadays embedded in the regular kernel.


I've used Ubuntu Studio for a long time until I've switched from a presonus audio to a Behringer UMC404HD. Guys here helped me a bunch, and I ended up uninstalling it, installed Linux Mint, added the KX Repositories (as suggested), did some tweeks, and now everything works fine.
Because UMC404 provides me a Zero Latency monitoring by the interface itself I kinda use it 20:40 (for the in/p knob position) then set the volume knob a little bit higher and everything works just fine with Harrison MixBus 4.1.3

I hope it helps


Return to “System Tuning and Configuration”

Who is online

Users browsing this forum: No registered users and 6 guests