Lots of Xruns with Carla

Unofficial support for the KXStudio Linux distribution and applications.
More info at http://kxstudio.linuxaudio.org/

Moderators: MattKingUSA, khz

Post Reply
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Lots of Xruns with Carla

Post by Tarrasque »

Hi.

I got back to kstudio and Linux music after a long time. I installed kstudio software from ppa over kubuntu LTS. My soundcard is an USB Scarlett 2i2.

I was then experimenting with reaper for Linux and some vst on Carla. Namely RandArp (win vst) and talk noisemaker. The objective was to make some vintage su the arpeggio a la hungry like the wolf or neverending story.

The basic setup works fine. I have the midi track in reaper routed to RandArp in random mode and then to the synth loaded in Carla. The problem is that I get lots of xruns every minute.

I tried with different combination of buffer size (from 128 to 512) and periods (2/3). Nothing helps. Xruns keep accumulating even with transport off.

The message I see in jack status is:
JackEngine::Xrun client = Carla was not finished, state = running
JackAudioDriver::ProcessGraphAsyncMaster: process error

According to Cadence my kernel is 5.3.0 generic and my user is not in audio group. I don't remember if this info matters anymore or how to fixed.

Can anybody help please?
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Yes I guess that's part of the problem.

Can you run this script from here and post the output?

https://github.com/raboof/realtimeconfigquickscan

Just open a terminal and execute

Code: Select all

git clone git://github.com/raboof/realtimeconfigquickscan.git
cd realtimeconfigquickscan
perl ./realTimeConfigQuickScan.pl
You need to install git first from your repository.
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

Here it is. Thank you very much for your help.

Code: Select all

$ perl ./realTimeConfigQuickScan.pl 
== GUI-enabled checks ==
Checking if you are root... no - good
Checking filesystem 'noatime' parameter... 5.3.0 kernel - good
(relatime is default since 2.6.30)
Checking CPU Governors... CPU 0: 'powersave' CPU 1: 'powersave' CPU 2: 'powersave' CPU 3: 'powersave'  - not good
Set CPU Governors to 'performance' with 'cpupower frequency-set -g performance' or 'cpufreq-set -c <cpunr> -g performance' (Debian/Ubuntu)
See also: http://linuxmusicians.com/viewtopic.php?f=27&t=844
Checking swappiness... 10 - good
Checking for resource-intensive background processes... none found - good
Checking checking sysctl inotify max_user_watches... < 524288 - not good
increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf
Checking access to the high precision event timer... not readable - not good
/dev/hpet found, but not readable.
make /dev/hpet readable by the 'audio' group
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#hardware_timers
Checking access to the real-time clock... not readable - not good
/dev/rtc found, but not readable.
make /dev/rtc readable by the 'audio' group
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#hardware_timers
Checking whether you're in the 'audio' group... no - not good
add yourself to the audio group with 'adduser $USER audio'
Checking for multiple 'audio' groups... no - good
chrt: failed to set pid 0's policy: Operation not permitted
Checking the ability to prioritize processes with chrt... no - not good
Could not assign a 80 rtprio SCHED_FIFO value. Set up limits.conf.
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#limitsconfaudioconf
Checking kernel support for high resolution timers... found - good
Kernel with Real-Time Preemption... not found - not good
Kernel without 'threadirqs' parameter or real-time capabilities found
For more information, see https://wiki.linuxaudio.org/wiki/system_configuration#do_i_really_need_a_real-time_kernel
Checking if kernel system timer is high-resolution... found - good
Checking kernel support for tickless timer... found - good
== Other checks ==
Checking filesystem types... ok.
** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks.
   Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Can you please check if you have kxstudio-default-settings installed? This script should adjust all of the crucial settings.
If not, please install it from the KX repo and reboot and again execute realtimeconfigscan.

Your CPU cores are not running at full speed which is for sure responsible for xruns.
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

I have that package (and all others I could install from kstudio PPA) installed.

Is there a script or tool I should run?

I think there's a lowlatency kernel available somewhere in the package manager to install. Could I just install it? Would it help? And in case, is it tricky to do it and/or are there any other steps I should take to enable it?

I'm on a multiboot setup with Windows, Manjaro and another regular Ubuntu 19.10 installed, in case it matters. I would really like not to mess up with the other systems.
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

That's strange, because the kx studio default setting package should do all these things for you.
@ others: That's right, isn't it?

You don't need the low latency kernel at the moment, that's one of the last things if you still need better performance.

Stupid question, but after adding the KX repo you also installed it, right? I guess so, because you have Carla already running.

Code: Select all

sudo apt update
sudo apt upgrade
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

lilith wrote: Wed Apr 15, 2020 10:21 pm That's strange, because the kx studio default setting package should do all these things for you.
@ others: That's right, isn't it?

You don't need the low latency kernel at the moment, that's one of the last things if you still need better performance.

Stupid question, but after adding the KX repo you also installed it, right? I guess so, because you have Carla already running.

Code: Select all

sudo apt update
sudo apt upgrade
I think i installed everything correctly. I istalled most if not every package from the PPA. I even have the KXStudio look and feel. Cadence, Carla, Claudia... every appseems to work, except for the latency issue.

One other thing I noticed that isn't working is that if I try to create an Ardour session it fails when trying to create the folder in my home folder. I didn't notice it before cecause I'm using Reaper. Could it be a permission problem at the root of both issues?

As a side note, if I set Jack to 1024 buffer size it seems to work without xruns.

So, what do you suggetst? Should i try reinstalling the setting package and see if it fixes it? Or trying to go through the quick scan suggestions one by one?
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Can you post the output of e.g. cat /etc/security/limits.d/audio.conf please? That's a folder which is for instance made by kx studio.
I would kxsudio make all the settings. Doing it by hand can potentially collide with settings kx studio is doing for you.
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

lilith wrote: Thu Apr 16, 2020 12:52 pm Can you post the output of e.g. cat /etc/security/limits.d/audio.conf please? That's a folder which is for instance made by kx studio.
I would kxsudio make all the settings. Doing it by hand can potentially collide with settings kx studio is doing for you.
sure, here it is.

$ cat /etc/security/limits.d/audio.conf
# Provided by the jackd package.
#
# Changes to this file will be preserved.
#
# If you want to enable/disable realtime permissions, run
#
# dpkg-reconfigure -p high jackd

@audio - rtprio 95
@audio - memlock unlimited
#@audio - nice -19
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Ok, then set the cpu governor to performance by hand as described here:

https://wiki.linuxaudio.org/wiki/system ... are_timers
Debian
On Debian you can control the scaling governor with the cpufreq-set utility which is part of the cpufrequtils package:

sudo cpufreq-set -r -g performance
On installation the package also installs an init script in /etc/init.d/cpufrequtils and a configuration file in /etc/default/cpufrequtils. To have the governor always set to performance make sure the configuration file looks as follows:

ENABLE="true"
GOVERNOR="performance"
MAX_SPEED="0"
MIN_SPEED="0"
Set your user to the audio group:

First check if you have an audio group with

Code: Select all

groups
. If so make:

Code: Select all

adduser $yourUSERname audio
You likely have to be root for these changes.

Install rtirq-init from your repository.

Reboot and post the output of realtimeconfig again.
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

The instructions on the wiki regarding cpufreq-set seem not to be up to date.

The correnc command should be

Code: Select all

cpufreq-set -c 0 -g performance
where 0 is the index of your processors (in my case I have to issue the command 4 times from 0 to 3)

After doing that the script teports the correct situation

Code: Select all

tarrasque@Tron:~/realtimeconfigquickscan$ perl ./realTimeConfigQuickScan.pl      
== GUI-enabled checks ==                                                                
Checking if you are root... no - good                                                   
Checking filesystem 'noatime' parameter... 5.3.0 kernel - good                          
(relatime is default since 2.6.30)                                                      
Checking CPU Governors... CPU 0: 'performance' CPU 1: 'performance' CPU 2: 'performance' CPU 3: 'performance'  - good                                                           
Checking swappiness... 10 - good                                                        
Checking for resource-intensive background processes... none found - good               
Checking checking sysctl inotify max_user_watches... < 524288 - not good                
increase max_user_watches by adding 'fs.inotify.max_user_watches = 524288' to /etc/sysctl.conf and rebooting                                                                    
For more information, see http://wiki.linuxaudio.org/wiki/system_configuration#sysctlconf                                                                                       
Checking access to the high precision event timer... readable - good
Checking access to the real-time clock... readable - good
Checking whether you're in the 'audio' group... yes - good
Checking for multiple 'audio' groups... no - good
Checking the ability to prioritize processes with chrt... yes - good
Checking kernel support for high resolution timers... found - good
Kernel with Real-Time Preemption... not found - not good
Kernel without 'threadirqs' parameter or real-time capabilities found
For more information, see https://wiki.linuxaudio.org/wiki/system_configuration#do_i_really_need_a_real-time_kernel
Checking if kernel system timer is high-resolution... found - good
Checking kernel support for tickless timer... found - good
== Other checks ==
Checking filesystem types... ok.
** Set $SOUND_CARD_IRQ to the IRQ of your soundcard to enable more checks.
   Find your sound card's IRQ by looking at '/proc/interrupts' and lspci.
Even though I created and edited the /etc/default/cpufrequtils it didn't seem to have any effect and after the reboot the script again reports

Code: Select all

Checking CPU Governors... CPU 0: 'powersave' CPU 1: 'powersave' CPU 2: 'powersave' CPU 3: 'powersave'  - not good
Regarding the audio group I fixed the issue.

For the sake of completeness, the

Code: Select all

groups
command only lists groups you user belongs to, not the full list. If you want to see it you must

Code: Select all

less /etc/group
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Does

Code: Select all

echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
work?

https://blog.sleeplessbeastie.eu/2015/1 ... r-at-boot/

This is also explained here: https://wiki.linuxaudio.org/wiki/system ... are_timers
Tarrasque
Established Member
Posts: 57
Joined: Thu Nov 04, 2010 12:43 pm

Re: Lots of Xruns with Carla

Post by Tarrasque »

lilith wrote: Fri Apr 17, 2020 10:44 am Does

Code: Select all

echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
work?

https://blog.sleeplessbeastie.eu/2015/1 ... r-at-boot/

This is also explained here: https://wiki.linuxaudio.org/wiki/system ... are_timers
The command outputs:

Code: Select all

$ echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor                                                           
bash: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor: ambiguous redirect  
I'm wondering: latest Ubuntu versions use systemd insted of initd.

Could it be that the start script that is supposed to set the governor is not executed at all at boot?

Maybe it's better to follow the systemd way?

Code: Select all

Create systemd service file to set CPU governor at system boot.

$ cat << EOF | sudo tee /etc/systemd/system/cpupower.service
[Unit]
Description=CPU powersave

[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower -c all frequency-set -g powersave

[Install]
WantedBy=multi-user.target
EOF
As detailed here: https://blog.sleeplessbeastie.eu/2015/1 ... r-at-boot/
User avatar
lilith
Established Member
Posts: 1698
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Has thanked: 117 times
Been thanked: 57 times
Contact:

Re: Lots of Xruns with Carla

Post by lilith »

Tarrasque wrote: Sun Apr 19, 2020 9:17 pm
lilith wrote: Fri Apr 17, 2020 10:44 am Does

Code: Select all

echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
work?

https://blog.sleeplessbeastie.eu/2015/1 ... r-at-boot/

This is also explained here: https://wiki.linuxaudio.org/wiki/system ... are_timers
The command outputs:

Code: Select all

$ echo -n performance > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor                                                           
bash: /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor: ambiguous redirect  
I'm wondering: latest Ubuntu versions use systemd insted of initd.

Could it be that the start script that is supposed to set the governor is not executed at all at boot?

Maybe it's better to follow the systemd way?

Code: Select all

Create systemd service file to set CPU governor at system boot.

$ cat << EOF | sudo tee /etc/systemd/system/cpupower.service
[Unit]
Description=CPU powersave

[Service]
Type=oneshot
ExecStart=/usr/bin/cpupower -c all frequency-set -g powersave

[Install]
WantedBy=multi-user.target
EOF
As detailed here: https://blog.sleeplessbeastie.eu/2015/1 ... r-at-boot/
Sorry, I think I was wrong. The CPU governor is not set by kxstudio. I have the kx default settings on my Laptop, but the governor has to be set by hand.
Post Reply