Giving realtime privileges to the right processes only

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Giving realtime privileges to the right processes only

Post by Musicteacher »

Hi,
after some break from linuxaudio (because of other projects), I took it up again and set up a new machine for realtime usage.

After adding my user to the realtime group (I'm on Arch, audio group on other platforms), I wondered if the all processes started by that user would have that higher priority? Is there another setting where I can specify which software exactly will get the higher privileges?

Background of that question is that on my system(s), I get good latency in general, but I get the occasional xrun once in a while, even though DSP load is below 30%. This means, in my understanding, that once in a while there is another process with a high priority that gets in the way of the audio processes. This should not happen if priorities are set up correctly on a system that is far away from having too much load to handle.

It would be nice if someone could explain this to me!

GuntherT
Established Member
Posts: 169
Joined: Sun Jun 07, 2015 2:15 am
Has thanked: 9 times
Been thanked: 28 times

Re: Giving realtime privileges to the right processes only

Post by GuntherT »

I haven't heard of prioritizing processes, but prioritizing the sound card is something that makes a noticeable difference on my computers. Have you added 'threadirqs' to GRUB and configured the rtirq script for your sound card? If not, I would start with that.

Last edited by GuntherT on Sat May 20, 2023 6:41 am, edited 2 times in total.
Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Giving realtime privileges to the right processes only

Post by Musicteacher »

Ok, probably I was being stupid for years.

I followed instructions like those:
https://jackaudio.org/faq/linux_rt_config.html
And, of course, used the script to check my settings (all ok), but overlooked that there is a dedicated setting in QJackCtrl where you can set the realtime priority.
This is very low in the default setting (at least on my machine), I've set this to 90 now, and played guitar for an hour, using my oldest and weakest notebook, not a single xrun (ok, it was guitar only, but this is a really weak machine).

Is there any advice which part of the audio chain should have which priority? It probably doesn't make sense to set jack to 90 and leave virtual instruments at a too low priority?

nils
Established Member
Posts: 538
Joined: Wed Oct 22, 2008 9:05 pm
Has thanked: 35 times
Been thanked: 94 times
Contact:

Re: Giving realtime privileges to the right processes only

Post by nils »

Since you are on Archlinux there is not much to do for you, since you don't need to do (almost) anything by hand to have it pro-audio ready.
Please have a look at this up-to-date article: https://wiki.archlinux.org/title/Professional_audio

You only need to read the very first chapter in 99% of the cases. In fact, I'll quote the important bit here:

Tip: However, if you are new to Arch Linux, just finished the Installation guide and cannot wait to actually start making music, install the pro-audio package group as well as realtime-generic-setup from AUR and reboot. Refer to the #PipeWire-only section for a quick setup and find your #Applications for music and sound production.

So, just install realtime-generic-setup from AUR and you are good to go. No manual config needed.

Background information: do not set the realtime priority of applications and plugins yourself. It in fact does the opposite of what you think.
The realtime priority is given to a single internal function in every JACK program (and subsequently plugins) which is called by jackd directly.
jackd is the process that needs priority. If you give high priority to another program you will actually give only the GUI part and non-audio part of that program high priority. That means the system will, if you are low on resources for a millisecond, prioritize drawing the GUI or fetching some program-news data from the internet instead of doing audio.

Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Giving realtime privileges to the right processes only

Post by Musicteacher »

Yes, thank you, I've done that.
My only problem was that in none of those howtos they say "be sure to check the advanced tab in qjackctl and set the realtime priority there".
The "default" was 10 or something like this, and there were other processes shown with ps that had way higher priority.

I am not sure if I had used that setting some 3 years ago when I did much recording and have forgotten about it or if it's really new to me.

Yes, it's all really easy to set up with Arch / Arch based, what I did was an error in userspace, so to say.
And thank you for the explanation that I don't need to set priorities for the other programs, I had hoped that but was not sure.

nils
Established Member
Posts: 538
Joined: Wed Oct 22, 2008 9:05 pm
Has thanked: 35 times
Been thanked: 94 times
Contact:

Re: Giving realtime privileges to the right processes only

Post by nils »

Lower numbers mean higher priority.

Priority values are inverted: lower p->prio value means higher priority.

Source:
http://lxr.linux.no/linux+v3.2.5/includ ... ed.h#L1580

Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Giving realtime privileges to the right processes only

Post by Musicteacher »

nils wrote: Sat May 20, 2023 10:43 am

Lower numbers mean higher priority.

Priority values are inverted: lower p->prio value means higher priority.

Source:
http://lxr.linux.no/linux+v3.2.5/includ ... ed.h#L1580

There are other sources who say the opposite:
viewtopic.php?t=11549

Also, on the Arch wiki, it says to set it at least 10 lower (!) that what is set in limits.conf (which ist 95 in most examples), I am confused now.

Musicteacher
Established Member
Posts: 194
Joined: Mon Nov 13, 2017 5:54 am
Has thanked: 8 times
Been thanked: 4 times

Re: Giving realtime privileges to the right processes only

Post by Musicteacher »

I looked this up. The "lower value means higher priority" is for normal processes only,not for realtime.

https://stackoverflow.com/questions/888 ... y-in-linux

Post Reply