Xrun every few minutes. Background process??

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
777funk
Established Member
Posts: 41
Joined: Mon Jun 02, 2014 1:50 am
Has thanked: 2 times
Been thanked: 1 time

Xrun every few minutes. Background process??

Post by 777funk »

I just setup a new system (Xubuntu 22.04 with Licorix) and it is running ok, but seems to be getting a few Xruns every 5 minutes or so regardless of settings (even at 44.1/256/3). It's not regular, just every so often so I think it's a background process and not my settings. It will Xrun at least once in a great while unless I turn settings up until I have say, 80-100ms of latency.

I did most of the configuration work taken from here:
https://github.com/chmaha/UbuntuProAudio

I also ran RTCQS to analyze my newly configured system. The only warnings I get are:

Code: Select all

[ WARNING ] The following mounts should be avoided for audio purposes: /run/user/1000/gvfs. See also https://wiki.linuxaudio.org/wiki/system_configuration#filesystems

and

Code: Select all

[ OK ] Soundcard snd_hda_intel:card1 with IRQ 27 does not share its IRQ.
[ WARNING ] Found USB port ehci_hcd:usb2 with IRQ 16 that shares its IRQ with the following other devices: ehci_hcd:usb2, firewire_ohci
Found USB port ehci_hcd:usb1 with IRQ 17 that shares its IRQ with the following other devices: ehci_hcd:usb1, wlp2s0

I'm thinking it is effected by some process going on in the background.

Is there a way to give video and everything else running on the PC (WLAN, etc) a lower priority? I would prefer to have ONLY audio if possible. Of course that's not practical. But I would like to tune to close to that if it's possible. I'm really thinking it's a background process (maybe video even - Dell Laptop with NVidea most likely).

Thanks for any tips! This thing sounds great but would love to get it up and running with no Xruns. It's close! Just not quite.

slangbein
Established Member
Posts: 13
Joined: Wed Dec 01, 2021 7:46 pm
Been thanked: 2 times

Re: Xrun every few minutes. Background process??

Post by slangbein »

ehci seems connected with bluetooth. I read people successful resolving the xruns with disabling network, Wifi, bluetooth. Maybe give it a try?

asbak
Established Member
Posts: 897
Joined: Thu Sep 11, 2014 3:04 pm
Has thanked: 71 times
Been thanked: 64 times

Re: Xrun every few minutes. Background process??

Post by asbak »

Get rid of snap completely, for starters.

Some Focal / 20.04 audio packages and resources https://midistudio.groups.io/g/linuxaudio
777funk
Established Member
Posts: 41
Joined: Mon Jun 02, 2014 1:50 am
Has thanked: 2 times
Been thanked: 1 time

Re: Xrun every few minutes. Background process??

Post by 777funk »

Got it figured out. It turns out to be a very easy fix.

I can now run live with Linux Sampler with Maestro Piano with some plugins in Reaper, a DX-7 EP in Dexed, a Pad in Surge XT, plus a Dragonfly Reverb Room and a Hall (ambient space), and if at 256 samples buffer and 11ms latency, I'm operating at around 20% DSP in Jack and with NO XRuns for several hours. If I'm not record armed on all of these VSTi tracks and just playing back pre-recorded MIDI tracks, I'm only at 4% DSP.

So I'm very happy with that, especially considering the old Dell Laptop (E6410).

The solution to eliminating my Xruns:
-Uncheck Enable Networking (from the menu)
-Turn off Bluetooth (from the menu)
-Keep any browsers closed

I could actually go less latency than this (and turn down to a 128 buffer for 5.6ms), but I can play with 11ms just fine. This runs great through both a Lexicon Lambda USB interface (2x2 plus MIDI) and through a Presonus Firebox (4x6 plus MIDI via Firewire). Both interfaces show up in Jack MIDI (as Jack MIDI and not only ALSA) as do my USB MIDI keyboards. All is working very very nice! I can play for hours without a blip both live MIDI and with recorded MIDI tracks.

Thanks to all who've helped. BEFORE starting this thread, I had done my due diligence and had already ran most of the tips in the link https://github.com/chmaha/UbuntuProAudio and am running Licquorix for the Kernel. I'm not sure which tweak helped most, but it all added up to a very nice system. If the results don't sound good, at this point, I'm the weak link... lol.

So thanks again for all the tips.

777funk
Established Member
Posts: 41
Joined: Mon Jun 02, 2014 1:50 am
Has thanked: 2 times
Been thanked: 1 time

Re: Xrun every few minutes. Background process??

Post by 777funk »

Nothing on the internet is forever, so for posterity's sake, here is most of the text on the link. I'm using Jack instead of Pipewire (had trouble with Pipewire).

Important: This guide will no longer be maintained as I have not used Ubuntu-based distros in a long time. Please visit https://github.com/chmaha/ArchProAudio for up-to-date information that is generally transferable to all distros with changes to package system commands.
A Pro Audio Tuning Guide for Ubuntu (and other Ubuntu/Debian-based distros)

Following this guide will hopefully allow you to get the best possible performance on Linux for professional audio needs. Even though these steps are well-tested, it is wise to research what each step accomplishes and why (the search engine is your friend :P ).
Fundamentals

To get started after installing Ubuntu, you could try just steps 2, 4 and 6 below. If you need to use windows plugins on Linux also follow step 12 (easy: wine-staging, more advanced but potentially more performance: wine-tkg). Based on your individual pro audio needs, workflows, hardware specifications and more, your mileage may vary. If you are still having audio performance issues, try following the full guide...
Pipewire?

Ubuntu includes a way of switching to Pipewire (see https://ubuntuhandbook.org/index.php/20 ... untu-2204/ & https://pipewire.org/ for more details). You may choose to wait until it ships as default in future releases although it is just as easy to roll things back. To switch to Pipewire run:

sudo apt install pipewire-audio-client-libraries libspa-0.2-bluetooth libspa-0.2-jack
sudo apt install wireplumber pipewire-media-session-
sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
sudo ldconfig
sudo apt remove pulseaudio-module-bluetooth
systemctl --user --now enable wireplumber.service
pactl info

Be sure to say 'yes' to removing conflicting packages. Reboot! It would also be wise to install a graph manager like qpwgraph to be able to make connections between apps and devices:

In distros that use Ubuntu 22.10 or Debian 12 repos and higher:

sudo apt install qpwgraph

otherwise,

flatpak install flathub org.rncbc.qpwgraph

For information on setting up flatpak see https://www.flatpak.org/setup/.

That should give you everything you need to get up and running. I consider Pipewire ready for primetime at this point. For Debian-specific instructions please see For Debian in particular see https://wiki.debian.org/PipeWire.
Pipewire configuration

If you want to change the default samplerate, buffer size etc, you need to copy /usr/share/pipewire/pipewire.conf over to /etc/pipewire/ and uncomment a few lines:

2022-04-19_09-19

To temporarily change samplerate/buffer size do not use PIPEWIRE_LATENCY environment variable. Instead, use:

pw-metadata -n settings 0 clock.force-rate <samplerate>

and

pw-metadata -n settings 0 clock.force-quantum <buffer-size>

To return to default values:

pw-metadata -n settings 0 clock.force-rate 0

and

pw-metadata -n settings 0 clock.force-quantum 0

See https://gitlab.freedesktop.org/pipewire ... uffer-size and https://gitlab.freedesktop.org/pipew...ormance-tuning for more details.
Back to ALSA/Pulse?

In the unlikely event you need to switch back:

sudo apt remove pipewire-audio-client-libraries libspa-0.2-bluetooth libspa-0.2-jack
sudo apt install pipewire-media-session wireplumber-
rm -f ~/.config/systemd/user/pipewire-session-manager.service
systemctl --user --now enable pipewire-media-session

If the sound still isn't working:

systemctl --user --now disable pipewire-pulse.service pipewire-pulse.socket
systemctl --user --now reenable pulseaudio.service pulseaudio.socket

substituting --user for --global if you originally enabled globally.
Full In-depth Guide

  1. Install a flavor of Ubuntu (or other favorite Ubuntu-based or Debian-based distro)

To make your life easier, install either Ubuntu Studio or AVLinux. Almost all of the following tweaks are taken care of. Otherwise, pick a regular distro such as Ubuntu, MXLinux etc.

  1. Install a low-latency kernel (Ubuntu-based)

sudo apt update && sudo apt upgrade -y
sudo apt install linux-lowlatency
reboot

Or, for even better performance:
Liquorix (Debian-based or Ubuntu-based)

sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common apt-transport-https wget ca-certificates gnupg2 ubuntu-keyring -y
sudo add-apt-repository ppa:damentz/liquorix -y
sudo apt update
sudo apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64 -y
reboot

  1. rtcqs (formerly known as realtimeconfigquickscan)

git clone https://codeberg.org/rtcqs/rtcqs.git
cd rtcqs
./src/rtcqs/rtcqs.py

  1. Add user to audio group and configure realtime privileges

I believe that installing jackd2 takes care of the following these days. It is always worth double-checking especially if using pipewire.

sudo nano /etc/security/limits.d/audio.conf

Add the following lines:

@audio - rtprio 95
@audio - memlock unlimited

Then create an audio group (if it doesn't exist already) and add your user to it:

sudo groupadd audio
sudo usermod -a -G audio $USER

Log out/in or reboot...

  1. Add "threadirqs" as kernel parameter

sudo nano /etc/default/grub

change GRUB_CMDLINE_LINUX="" to GRUB_CMDLINE_LINUX="threadirqs"

sudo update-grub

  1. Set governor to "performance"

i. Temporary:

sudo cpupower frequency-set -g performance

ii. Permanent:

Add cpufreq.default_governor=performance as a kernel parameter:

sudo nano /etc/default/grub

LIne should now read:

GRUB_CMDLINE_LINUX="cpufreq.default_governor=performance threadirqs"

sudo update-grub

or, for kernels < 5.9:

sudo nano /etc/default/cpupower # uncomment governor and change to performance
systemctl enable --now cpupower.service
systemctl start cpupower.service

  1. Swappiness

sudo nano /etc/sysctl.d/99-sysctl.conf

add "vm.swappiness=10"

  1. Spectre/Meltdown Mitigations

If you run rtcqs.py and it gives you a warning about Spectre/Meltdown Mitigations, you could add mitigations=off to GRUB_CMDLINE_LINUX. Warning: disabling these mitigations will make your machine less secure! https://wiki.linuxaudio.org/wiki/system ... itigations

  1. Install udev-rtirq

git clone https://github.com/jhernberg/udev-rtirq.git
cd udev-rtirq
sudo make install
reboot

  1. Jack2 + Jack D-Bus (skip this step if you switched to Pipewire)

sudo apt install qjackctl jackd2

Enable Jack D-Bus interface:
image

  1. DAW & Plugins

REAPER: http://reaper.fm/download.php

Post Reply