[SOLVED] Is a realtime kernel needed?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Brynildsen
Established Member
Posts: 24
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
Established Member
Posts: 112
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
Established 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
Established Member
Posts: 960
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
Established Member
Posts: 639
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
Established Member
Posts: 293
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, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

Brynildsen
Established Member
Posts: 24
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
Established Member
Posts: 293
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, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

asbak
Established Member
Posts: 639
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
Established Member
Posts: 20
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
Established Member
Posts: 26
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

Dominique
Established Member
Posts: 12
Joined: Sat May 26, 2018 10:24 am

Re: [SOLVED] Is a realtime kernel needed?

Postby Dominique » Sat May 26, 2018 10:53 am

To answer the initial question, I would say it depend. I use linux from years. Back in time, the only way to get decent performances with JACK was a realtime kernel. I was on Suse at that time, and after trying the first audio distribution like Agnula, I ended making my own realtime kernel on suse.

Now the situation is different. The cgroups did their way into the kernel and most distributions are using them for systemd. I don't like at all this situation because, as most distributions are using systemd, you will need the cgroups even with a rt-kernel, the result being in that case you get 2 concurrent systems - the rt preemption and the cgroups - managing the task priority. It is even more with the cgroups: on a "regular" non rt kernel, you will get a lot of stuffs into the rt cgroup which are not related to audio. From my point of view. managing the cgroups for rt operation with JACK is really messy and time consuming (you have to add every single software using JACK into the cgroup config).

Also I know by experience, being an electronics engineer, that if you have several ways to achieve the same result, the simplest one will generally give you the best result. And here a rt-kernel is definitely the best solution, it is simple, easy to setup, well tested from many years, and just do its work.

When I understand the need of big corporations for stuffs like systemd or the cgroups, I really prefer to avoid them as long as I can into my home computer (It is one of the main reason I am using gentoo: choice). But now it depend also of which distribution you are using, and BOUT what you want or are willing/able to do. On a distribution using systemd, it will be impossible to not have the cgroups up and running, so I think you will be better avoiding using to concurrent systems of managing the tasks poriority, which imply using the "regular" kernel provided by the distribution, and set it up for audio work as best as possible.

Jack Winter
Established Member
Posts: 293
Joined: Sun May 28, 2017 3:52 pm

Re: [SOLVED] Is a realtime kernel needed?

Postby Jack Winter » Sat May 26, 2018 12:25 pm

Is the use of cgroups really a problem with systemd based distros?

I've never ran into this problem with Archlinux, and didn't even know that it used cgroups to manage realtime..
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux

Drumfix
Established Member
Posts: 185
Joined: Mon Jan 26, 2009 5:15 pm

Re: [SOLVED] Is a realtime kernel needed?

Postby Drumfix » Sat May 26, 2018 7:59 pm

On any cpu with more than a single core the isolcpus= boot option is the perferred way to achieve latencies < 10 microseconds, together with a few conventions about software design and interrupt assignment.
Unfortunately the audio community ignores it.

Jack Winter
Established Member
Posts: 293
Joined: Sun May 28, 2017 3:52 pm

Re: [SOLVED] Is a realtime kernel needed?

Postby Jack Winter » Sat May 26, 2018 9:21 pm

How would you use it?

Isolate one cpu and run the interrupt handling thread and jackd's processing thread(s) on it? Or more than that?
Reaper/KDE/Archlinux. i7-2600k/16GB + i7-4700HQ/16GB, RME Multiface/Babyface, Behringer X32, WA273-EQ, 2 x WA-412, ADL-600, Tegeler TRC, etc 8) For REAPER on Linux information: https://wiki.cockos.com/wiki/index.php/REAPER_for_Linux


Return to “System Tuning and Configuration”

Who is online

Users browsing this forum: No registered users and 2 guests