[SOLVED] Waves of xruns with long, irregular intervals in between

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
Oliver
Established Member
Posts: 4
Joined: Sun Dec 13, 2020 2:54 pm

[SOLVED] Waves of xruns with long, irregular intervals in between

Post by Oliver »

With an external USB sound card (part of an Allen&Heath ZED 10 mixer) and using 64 frames/period and 2 periods/buffer, I get waves of xruns (hundreds to thousands), with long quiet intervals in between (duration tens of minutes to hours).

During such a wave (lasts from ~10 secs to a minute), I hear a low-frequency humming sound, sometimes changing pitch a little before it recovers. qjackctl shows many messages 'XRUN callback (nnn skipped).'

No particular audio processing is done (also happens when nothing is playing). Both CPU and DSP loads are at a few percent. During such a wave, the load does not go up, nothing particular seen in top.

It also happens with 128 and 256 frames/period. Only at 512 frames or longer does the issue not appear to occur at all anymore.

Has anyone experienced such a behaviour before and could shed some light on a possible cause/remedy?


Testing done so far

All of the following was tested and did not improve the issue:
  • PREEMPT_RT kernel (normally I use lowlatency), also GRUB_CMDLINE_LINUX="threadirqs" is set
  • Disabling the on-board sound completely in BIOS, or unloading the Pulse modules jack-source/jack-sink
  • Removing a2jmidi
  • Disabling AMD Cool’n’Quiet (frequency throtteling) in the BIOS (usually I use the performance frequency governor)
  • Disabling SMT (CPU multithreading) in the BIOS
  • Using the rtirq script to boost the realtime priority of the USB bus interrupt (IRQ 57). I verified that this IRQ does actually is boosted.
  • Stopping JACK and using ALSA directly with Ardour in an empty session.
  • Using 3 periods/buffer in JACK
I did not attempt all the (many) combinations of these measures.

Set-up
  • Xubuntu 20.04 LTS
  • AMD Ryzen 5 3400G (on-board graphics) on Gigabyte B450M S2H mainboard, 16 GByte RAM
  • Three SATA devices: an SSD, a harddisk (not mounted), and a DVD drive (not used)
  • Mainboard audio handled by Pulse, USB audio by JACK, a2jmidi for bridging ALSA MIDI
  • USB sound card is the only device on its USB bus
  • No swap enabled
All checkpoints of the 'realtimeconfigquickscan' script are indicated green/good.

I recently upgraded from a eleven-year old system, and wanted to explore smaller latencies than before.
Last edited by Oliver on Tue Dec 15, 2020 3:20 pm, edited 1 time in total.
JamesPeters
Established Member
Posts: 188
Joined: Fri Jun 29, 2018 6:35 pm
Has thanked: 8 times
Been thanked: 15 times

Re: Waves of xruns with long, irregular intervals in between

Post by JamesPeters »

I'd re-enable hyperthreading. That's not likely to be the problem, and it can help your performance.

Since I use Reaper and plugins "within Reaper" only (no standalone synths/plugins connected via Jack), I don't have to do much for my system to perform very well. My CPU is a Ryzen 7 3700X.

In Windows there are "power settings" to adjust and/or choose from a profile in the control panel, which should be done for DAW use. Linux generally doesn't have settings dialogs like this (although some distros have more control-panel-like things). A couple of the things you'd be doing by choosing the "high performance" power profile in Windows should also be done in Linux.
  • For USB audio devices, you should check your "USB autosuspend" setting and probably just disable it entirely. Some USB audio devices can aggressively autosuspend (something I learned the hard way) and on certain USB ports (and in certain distros) it's worse than others. When using Pulse with "average settings" you might not notice, but for low latency use (ALSA, Jack) you'll notice. This is probably the issue.
  • For your "CPU frequency governor", you want that set to "performance" so that the CPU speed doesn't throttle down to a lower speed. That throttling can cause xruns. This isn't as important as the USB autosuspend setting, but it's good to do it to keep the system stable under varying CPU loads.
  • For PCIe audio devices, you may also need to check your "PCIe ASPM" setting and change it to "performance".
I'm currently using Manjaro, so I can do all this using TLP (in particular I use the front-end TLP-UI which I had to add from the repo). You may have to change settings in some files, or use some other utilities, in other distros. You'll probably have to search for that information.

Other than those settings, I do the following (which you've already done): Install a lowlatency or realtime kernel. Along with this, depending on the distro, I may have to add a module for the Nvidia proprietary driver for the GPU that I'm using so that it's compatible with the realtime or lowlatency kernel. (Ubuntu-based distros seem to pull in the rt module for the proprietary Nvidia driver automatically when using a lowlatency kernel from the repo, but other distros don't seem to do this.)

For DAW use which requires using Jack and connecting multiple apps, you may need to adjust priority of the USB device etc. (as you've done) but I never need to do that. I use 3 periods of 64 samples with ALSA in Reaper, and my "super safe" setting is using 4 periods of 64 samples (stable up to 90% CPU use with no xruns).
User avatar
Michael Willis
Established Member
Posts: 1458
Joined: Mon Oct 03, 2016 3:27 pm
Location: Rocky Mountains, North America
Has thanked: 70 times
Been thanked: 167 times
Contact:

Re: Waves of xruns with long, irregular intervals in between

Post by Michael Willis »

Please take a look at https://wiki.linuxaudio.org/wiki/list_o ... _interface - it suggests that you might get better results with 3 periods per buffer.
christobal
Established Member
Posts: 108
Joined: Sun Sep 01, 2019 12:58 pm
Has thanked: 21 times
Been thanked: 11 times

Re: Waves of xruns with long, irregular intervals in between

Post by christobal »

JamesPeters wrote: Tue Dec 15, 2020 2:36 am
I'm currently using Manjaro, so I can do all this using TLP (in particular I use the front-end TLP-UI which I had to add from the repo). You may have to change settings in some files, or use some other utilities, in other distros. You'll probably have to search for that information.

I have been struggling with x-runs at anything below 48/256/3 (I have 3700x as well, MSI b450 board and 32gb 3200mhz ram)

Even trying all of this as well as all the rtirq stuff, testing OK on everything on the realtimequickscan, I'm still stuck at AT BEST 48/128 (even that isnt really fully stable)
OS: Manjaro
Amp: Echolette M40 / NG51S Tape Echo
Strings: Martin D15M, Yamaha FG-180, Alhambra 5P, Yamaha Revstar
Oliver
Established Member
Posts: 4
Joined: Sun Dec 13, 2020 2:54 pm

Re: Waves of xruns with long, irregular intervals in between

Post by Oliver »

Thanks JamesPeters for bringing up "USB autosuspend"!

In the meantime I have also found a casual mention of this in another discussion thread, and indeed for me that's the key. I added

Code: Select all

usbcore.autosuspend=-1
to the kernel boot parameters in /etc/default/grub, and now it runs smoothly for hours at 64 frames/period and two periods without any xrun (except briefly just after booting, which is acceptable)

I wonder what a terrible mechanism that is, suspending a working sound device in flight.

As extra information for other readers, for me it seems not necessary to use the rtirq script to boost interrupt priorities. However, the realtime kernel makes a difference at this short buffer size compared to the lowlatency one. With the latter, I do get individual xruns from time to time.
christobal
Established Member
Posts: 108
Joined: Sun Sep 01, 2019 12:58 pm
Has thanked: 21 times
Been thanked: 11 times

Re: [SOLVED] Waves of xruns with long, irregular intervals in between

Post by christobal »

So we are both on b450, both on 3xxx series amd, but I have nvidia and you have amd integrated graphics.

If I put 64/2 i just get a constant stream of xruns from the moment jack connects.

I also get all green on relatimecheck and the same problems occured when i tested avlinux, which does not use prop. nvidia drivers oob.

Gaaaah I'm starting to get frustrated by this.
OS: Manjaro
Amp: Echolette M40 / NG51S Tape Echo
Strings: Martin D15M, Yamaha FG-180, Alhambra 5P, Yamaha Revstar
JamesPeters
Established Member
Posts: 188
Joined: Fri Jun 29, 2018 6:35 pm
Has thanked: 8 times
Been thanked: 15 times

Re: Waves of xruns with long, irregular intervals in between

Post by JamesPeters »

christobal wrote: Tue Dec 15, 2020 1:29 pm I have been struggling with x-runs at anything below 48/256/3 (I have 3700x as well, MSI b450 board and 32gb 3200mhz ram)

Even trying all of this as well as all the rtirq stuff, testing OK on everything on the realtimequickscan, I'm still stuck at AT BEST 48/128 (even that isnt really fully stable)
To recap, here is how I run my system:

-using Manjaro 20.2
-RT kernel from the Manjaro repo (currently version 5.9.1_rt-19-1)
-the latest proprietary Nvidia driver and RT module for it (since I'm using the RT kernel)
-Reaper for Linux as the DAW
-not resampling on-the-fly (if a project is 44.1 KHz, I only use 44.1 KHz media in it for instance)
-no bridging of any kind, only native Linux software/plugins
-all plugins are running within Reaper (no standalone synths connected via Jack etc.)
-ALSA as the audio system, not Jack
-CPU governor set to "Performance"
-USB autosuspend disabled (for my USB audio device, 3rd generation Focusrite Scarlett 2i2)

If you're doing the same as all the above, I wouldn't know where to start looking.

If you're doing anything different, that might be a place to start looking. For instance you didn't mention what audio interface you have, what sample rate you're using (I usually use 44.1 KHz), if you're trying to use Windows plugins in Linux in some way, how many things you're trying to connect with Jack (or if there's some odd configuration in Jack on your computer that might be causing this), or what version of Manjaro you're using. So I'm at a loss.

I've used a bunch of other distros and kernels over the last 2 years, and generally speaking it's worked out fine for me if I did the same things. I've used a couple other audio interfaces too (PCIe and USB). Then again since I use everything "within Reaper" (no standalone synths connected via Jack etc.), it's likely I'm having an easier time of this than you.

@Oliver : I'm glad to have contributed to your solution! Yes I find it odd that all the distros I've used so far don't have (what I consider) basic power management settings in some "control panel-type" app, such as in Windows. I know a Linux distro is basically a piecemeal collection of applications "connected to" the kernel, but even so I figured by now enough people would realize the importance of things like this, so that it would be included in more common distros (and not require people to dig around the Internet to try to figure out how to do these things). I had tried a lot of things to resolve my issues, and there's no shortage of suggestions (some of which are useless with more recent kernels, or might actually make performance worse in some way). Meanwhile this was right under my nose.
User avatar
raboof
Established Member
Posts: 1855
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 50 times
Been thanked: 74 times
Contact:

Re: Waves of xruns with long, irregular intervals in between

Post by raboof »

Oliver wrote: Tue Dec 15, 2020 3:18 pm Thanks JamesPeters for bringing up "USB autosuspend"!

In the meantime I have also found a casual mention of this in another discussion thread, and indeed for me that's the key. I added

Code: Select all

usbcore.autosuspend=-1
to the kernel boot parameters in /etc/default/grub, and now it runs smoothly
It would be great if someone could contribute a check for this to realtimeconfigquickscan, just sayin' :)
Post Reply