Jack xrun every 1.5-2 seconds. What am I missing?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
theherk
Posts: 2
Joined: Thu Jan 02, 2014 2:16 pm

Jack xrun every 1.5-2 seconds. What am I missing?

Post by theherk »

I have searched high and low for an answer and I just can't figure this out.

setup: Ubuntu 13.10 64, 32 GB RAM, i7-4770k. I have tried generic, lowlatency, and rt kernels with the same result. I have disable the ondemand cpu governer. I have changed the settings in Jack in every way. I think my rig is sporting enough power to handle this, especially considering my Arch rig, which is a Phenom II X4 960 with 8 GB RAM never got any xruns.

I have set up and run the perl tool from https://github.com/raboof/realtimeconfigquickscan. It only complains about a few things. My swappiness, which I am assuming is not the issue since I have loads of RAM. Also, it report that it finds the "noatime" parameter. That's it. Everything else is good.

So what is going on? Please help. Thank you.

Code: Select all

uname -a
Linux Smaug 3.11.0-14-lowlatency #6-Ubuntu SMP PREEMPT Wed Nov 20 23:59:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Code: Select all

ulimit -r -l
real-time priority              (-r) 95
max locked memory       (kbytes, -l) unlimited

Code: Select all

cat /proc/asound/cards
 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7330000 irq 45
 1 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xf7080000 irq 17
 2 [Microphone     ]: USB-Audio - Yeti Stereo Microphone
                      Blue Microphones Yeti Stereo Microphone at usb-0000:00:14.0-9, full speed
edit 1: I wanted to add some of the qjackctl output so you can see how consistent the times are:

Code: Select all

08:59:55.007 XRUN callback (1).
09:01:42.805 XRUN callback (2).
09:03:29.977 XRUN callback (3).
09:05:17.775 XRUN callback (4).
09:07:06.943 XRUN callback (5).
09:09:28.375 XRUN callback (6).
09:11:50.283 XRUN callback (7).
09:13:37.663 XRUN callback (8).
09:16:00.465 XRUN callback (9).
09:17:47.370 XRUN callback (10).
09:20:11.066 XRUN callback (11).
09:22:32.916 XRUN callback (12).
09:24:19.402 XRUN callback (13).
09:26:07.259 XRUN callback (14).
09:28:44.213 XRUN callback (15).
09:31:05.170 XRUN callback (16).
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: Jack xrun every 1.5-2 seconds. What am I missing?

Post by raboof »

theherk wrote:I have searched high and low for an answer and I just can't figure this out.

So what is going on? Please help. Thank you.
While I'm (still) no expert on this, I'd (still) like to become one :).
theherk wrote:

Code: Select all

uname -a
Linux Smaug 3.11.0-14-lowlatency #6-Ubuntu SMP PREEMPT Wed Nov 20 23:59:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
As you said your machine should be plenty powerful, so I think it'd be interesting to test this with a kernel with PREEMPT_RT enabled. Very roughly PREEMPT_RT trades some throughput for more reliable latency. While PREEMPT these days has many of the benefits of PREEMPT_RT, I think PREEMPT_RT still contains some useful tidbits for rare situations - who knows you might be in such a rare situation :).

So could you try the same again with a PREEMPT_RT kernel, and show the output of

Code: Select all

ps -eo rtprio,pid,tid,class,ni,pri,psr,pcpu,stat,comm | sort -n | grep -ve "^ *-"
? That should show which threads have realtime priority.

Which jackd version are you using? What are your exact jackd settings? Are you getting these xruns always, also with high 'periods/buffer' and 'frames/period' values? Which devices are you using (for input and for output)? do you have 'Realtime' enabled in jack?

Oh, also /proc/interrupts should be interesting, and which video card driver are you using?
theherk
Posts: 2
Joined: Thu Jan 02, 2014 2:16 pm

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by theherk »

Thank you for the reply. First, I did test with the rt kernel, as well. Though I would be willing to again for troubleshooting, I may not at this point. I have run pretty consistently for several hours now. Here are a list of modifications since trouble that may have caused the success.
  • I modified /etc/security/limits.d/audio.conf to uncomment @audio - nice -19. I actually don't know what that does, but it showed up in about half the PAM examples.
  • I changed the Sample Rate in Jack to 48k. I had used that previously, but I was wrestling with several problems, so it wasn't then clear that my audio card did not like 44.1k.
  • I turned of the daemon that set cpu governors to ondemand and with cpufrequtils manually ramped them all up to performance.
  • Added -S to the server prefix for synchronous mode (recommended elsewhere), so that may be the trick.
There were times when I adjusted the settings so extremely that my latency was over 100 ms and I still had the same error just as regularly. I have been using Jack 1.9.10 which I believe is Jack 2, but truthfully I am confused about which is which and how to control which is called. As far as the devices, I am using default for output, which is the Intel HDA, and I'm using the Yeti as input.

At any rate, I am not certain what caused or solved the problem, but I suspect it had the most to do with the cpu governors. Even though I said that I had disabled them in the original post, they were being re-enabled by the daemon and I did not know it for a while.

edit 1: I failed to mention that the interrupts don't seem that interesting. When I checked it earlier, I was hoping to see the Intel HDA share an interrupt with another device, but it doesn't look that way.

Code: Select all

           CPU0       CPU1       CPU2       CPU3       CPU4       CPU5       CPU6       CPU7       
  0:         40          0          0          0          0          0          0          0   IO-APIC-edge      timer
  1:          1          0          0          0          0          0          2          0   IO-APIC-edge      i8042
  8:          0          1          0          0          0          0          0          0   IO-APIC-edge      rtc0
  9:          0          0          0          0          0          0          0          0   IO-APIC-fasteoi   acpi
 12:          3          0          0          0          0          0          0          1   IO-APIC-edge      i8042
 16:     853811         34        247         44    6549554        218       2799       2687   IO-APIC-fasteoi   ehci_hcd:usb1, nvidia, blackmagic0
 17:         74         13         44          1         28         19          9         45   IO-APIC-fasteoi   snd_hda_intel
 23:          7          1          2          0         15          2          7          3   IO-APIC-fasteoi   ehci_hcd:usb2
 41:       2161         54    4342730      10482        230       1738   41252899     142599   PCI-MSI-edge      xhci_hcd
 42:       9092       1181        832      12844       3935       1490        725      69862   PCI-MSI-edge      ahci
 43:        142      54259          1          2          9         25         24          3   PCI-MSI-edge      eth0
 44:          8          0          2          0          1          0          0          0   PCI-MSI-edge      mei_me
 45:      90901       2633       4014       2325       3756       4153       3275       2725   PCI-MSI-edge      snd_hda_intel
NMI:         92         82        107         76         68         36         54         29   Non-maskable interrupts
LOC:    3183815    3353372    2632912    3065660     745698     475875     509999     542842   Local timer interrupts
SPU:          0          0          0          0          0          0          0          0   Spurious interrupts
PMI:         92         82        107         76         68         36         54         29   Performance monitoring interrupts
IWI:      12333      10542      12822      13757       3448       3989       6097       5177   IRQ work interrupts
RTR:          7          0          0          0          0          0          0          0   APIC ICR read retries
RES:   16033421   11344846   35223308    8142512    7385878   13338476    8655502    6014264   Rescheduling interrupts
CAL:        859        808        876        838        881        875        822        873   Function call interrupts
TLB:       3199       5406       9336       2755       2122       2571       3604       2334   TLB shootdowns
TRM:          0          0          0          0          0          0          0          0   Thermal event interrupts
THR:          0          0          0          0          0          0          0          0   Threshold APIC interrupts
MCE:          0          0          0          0          0          0          0          0   Machine check exceptions
MCP:        120        120        120        120        120        120        120        120   Machine check polls
User avatar
AnthonyCFox
Established Member
Posts: 393
Joined: Mon Apr 22, 2013 3:50 pm
Been thanked: 1 time

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by AnthonyCFox »

theherk wrote: [*]I changed the Sample Rate in Jack to 48k. I had used that previously, but I was wrestling with several problems, so it wasn't then clear that my audio card did not like 44.1k.
I thought of that when I saw your post earlier but you're clearly pro-audio savvy, so I figured the problem must be something else. I can see though, how if you were struggling with other issues at the same time, it would be hard to tell what setting was appropriate. :D
War, crime, disease, starvation, extreme poverty; these are serious things.
Music? Not so serious. Have some fun! :D
Frank Carvalho
Established Member
Posts: 363
Joined: Sat Nov 17, 2012 3:36 pm

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by Frank Carvalho »

Hi

I posted a similar problem a few weeks ago:
http://linuxmusicians.com/viewtopic.php?f=27&t=11896
but noone replied. However the problem you describe is very similar to mine, so I looked into the suggestions here, and following the different clues, I came to the conclusion that my xruns issues had to do with the settings of the CPU governor. It seems that if CPU governor is set to "ondemand", it will lower the CPU frequency for power saving reasons. This however is not very practical in an audio high-performance environment. But it can also be set to "performance" which causes it to not scale down CPU frequency. It so happened that my setup was indeed set to CPU governor "ondemand", and I think that setting it to "performance" has solved my problem.
As my machine is essentially a Xubuntu, the GNOME-based suggestions are not viable, but setting it this way works:

Code: Select all

sudo update-rc.d ondemand disable
as suggested in this thread:
http://ubuntuforums.org/showthread.php?t=1810031

...and then of course Cadence also has a checkbox where you may choose "performance". Just I am not sure if the change persists across reboot.

/Frank
Vox, Selmer, Yamaha and Leslie amplifiers. Rickenbacker, Epiphone, Ibanez, Washburn, Segovia, Yamaha and Fender guitars. Hammond, Moog, Roland, Korg, Yamaha, Crumar, Ensoniq and Mellotron keyboards. Xubuntu+KXStudio recording setup.
AndreeeCZ
Established Member
Posts: 29
Joined: Tue Jun 26, 2012 10:01 am

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by AndreeeCZ »

Yes, i have had that same problem too.

One thing you should do is turn the governor to performance (i hear that things are different with pstate, but dunno)
And the other, with which i had problems was automatic fan control on a laptop. The thing was that the deamon polled for CPU temperature (sensors) and that somehow was bypassing the kernel, so everytime that happened, i had an xrun. So I solved this by having a hotkey that turns performance governor on, disables fan daemon and turns fan to max. (Only for live stuff though - <=256buffer).

My laptop is Dell 3560 .

Hope this might help someone in the future.
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: Jack xrun every 1.5-2 seconds. What am I missing?

Post by raboof »

AndreeeCZ wrote:automatic fan control on a laptop. The thing was that the deamon polled for CPU temperature (sensors) and that somehow was bypassing the kernel, so everytime that happened, i had an xrun.
That's really interesting. Can you trigger that manually? I wonder if I can reproduce that on my laptop (though it might be hardware-dependent of course)
Shadow_7
Established Member
Posts: 175
Joined: Tue Jun 08, 2010 3:35 pm

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by Shadow_7 »

If you're running pulseaudio over jack, it tends to play nicer at 48kHz.

CPU frequency scaling can be a bit quirky. AFAIK it still throttles down (some) under the performance governor. So you might hard set the min and max values to the same value to prevent that when doing latency sensitive stuff. Via cpufreq-info and cpufreq-set on the CLI. And of course undo that manually when saving power and not needing it.

With that much RAM you might consider making a ramdisk. And put things like soundfonts that would otherwise load from disk in the ramdisk. A copy of course as you'll need to redo that every boot since RAM is not persistent. An SSD can be worse in terms of write speeds than an HDD. Recording to RAM is not ideal, but probably an option with that much RAM.

Not that you should need to do any of that on a system that beefy.
Frank Carvalho
Established Member
Posts: 363
Joined: Sat Nov 17, 2012 3:36 pm

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by Frank Carvalho »

I think I said that setting the CPU scling governor right, had solved my problem. But it has not. I explain in the separate thread I opened.
/Frank
Vox, Selmer, Yamaha and Leslie amplifiers. Rickenbacker, Epiphone, Ibanez, Washburn, Segovia, Yamaha and Fender guitars. Hammond, Moog, Roland, Korg, Yamaha, Crumar, Ensoniq and Mellotron keyboards. Xubuntu+KXStudio recording setup.
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: Jack xrun every 1.5-2 seconds. What am I missing?

Post by raboof »

Frank Carvalho wrote:I think I said that setting the CPU scling governor right, had solved my problem. But it has not. I explain in the separate thread I opened.
That's probably http://www.linuxmusicians.com/viewtopic ... 199#p49199 ?
AndreeeCZ
Established Member
Posts: 29
Joined: Tue Jun 26, 2012 10:01 am

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by AndreeeCZ »

raboof wrote:
AndreeeCZ wrote:automatic fan control on a laptop. The thing was that the deamon polled for CPU temperature (sensors) and that somehow was bypassing the kernel, so everytime that happened, i had an xrun.
That's really interesting. Can you trigger that manually? I wonder if I can reproduce that on my laptop (though it might be hardware-dependent of course)
It is being managed by the i7kmon daemon. I didnt look into it in more detail, as folks on #linux-rt have told me (after me giving them info) that it's dell's stupid crap and I cannot do anything about it and need to resort to my solution above.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by bluebell »

Frank Carvalho wrote:Hi

I posted a similar problem a few weeks ago:
http://linuxmusicians.com/viewtopic.php?f=27&t=11896
but noone replied. However the problem you describe is very similar to mine, so I looked into the suggestions here, and following the different clues, I came to the conclusion that my xruns issues had to do with the settings of the CPU governor. It seems that if CPU governor is set to "ondemand", it will lower the CPU frequency for power saving reasons. This however is not very practical in an audio high-performance environment. But it can also be set to "performance" which causes it to not scale down CPU frequency. It so happened that my setup was indeed set to CPU governor "ondemand", and I think that setting it to "performance" has solved my problem.
As my machine is essentially a Xubuntu, the GNOME-based suggestions are not viable, but setting it this way works:

Code: Select all

sudo update-rc.d ondemand disable
as suggested in this thread:
http://ubuntuforums.org/showthread.php?t=1810031

...and then of course Cadence also has a checkbox where you may choose "performance". Just I am not sure if the change persists across reboot.

/Frank
I chose a differnet approach: I use "ondemand" and force max. CPU frequency with cpufreqd. I have a rule in cpufreqd.conf that uses 100% CPU freqency when qtractor, rosegarden or jamin are running.

Unfortunately that doesn't work when my new Laptop is running without AC. The core i5 CPU seems to be "hardware-limited" to a lower freqency. But with my desktop and the laptop running with AC connected it works like a charm.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by bluebell »

Just for ther record, my /etc/cpufreqd.conf:

#-- Profiles ---------------------------------------

[Profile]
name=On_Demand_High
minfreq=100%
maxfreq=100%
policy=ondemand
[/Profile]

[Profile]
name=On_Demand_Standard
minfreq=0%
maxfreq=100%
policy=ondemand
[/Profile]

#-- Rules ------------------------------------------

[Rule]
name=Standard_Rule
cpu_interval=0-100
profile=On_Demand_Standard
[/Rule]

[Rule]
name=CPU_Too_Hot
acpi_temperature=60-100
cpu_interval=50-100
profile=On_Demand_Standard
[/Rule]

[Rule]
name=Music_Production
programs=rosegarden,jamin,qtractor
cpu_interval=0-100
profile=On_Demand_High
[/Rule]

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

brianmc
Established Member
Posts: 4
Joined: Sat Mar 15, 2014 6:29 pm

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by brianmc »

Bluebell, Thank you for posting those cpufreqd.conf rules!

They've turned out to be an absolute 'Geeksend' in-terms of resolving some niggling problems in getting my system to quit spitting out Xruns.

I can still provoke the odd Xrun, but that's when doing something daft like recompiling the kernel on two cores. Even then, the Xrun reported is only (for example) "of at least 0.017 msecs". :P This is when running on an i5 with 32 Frames/Period, Sample Rate of 96kHz, and 2 Periods/Buffer.

I'd gone down the route of compiling an -rt kernel (3.12.13-rt21) for use in Ubuntu Studio, but still had Xruns even when cutting a lot of the fat out. Where I'd previously recompiled the -lowlatency kernel for an AMD64 platform, trimming out debug, crash dump, etc, I found the RT DSP load almost-halved, and varying far, far less.
User avatar
bluebell
Established Member
Posts: 1924
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland, Germany
Has thanked: 112 times
Been thanked: 119 times

Re: Jack xrun every 1.5-2 seconds. What am I missing?

Post by bluebell »

My last big win came from setting the realtime priority of jackd:

/usr/bin/jackd -P95 -p512 -t2000 -dalsa -r44100 -p256 -n3 -M -Xseq -D -Chw:3 -Phw:3 >/tmp/jackd-hm.log 2>&1

The arg "-P95" adds some more xrunlessness in my universe even with more than 50% rt-cpu.
53.png
53.png (30.3 KiB) Viewed 2215 times
Now I use a stock kernel 3.12 with active intel_pstate driver (adjusts the cpu cores indepently) I don't use cpufreqd anymore.
It's a core i5 system, 4 cores, max 2,3 GHz (+ turbo boost sometimes on one core) running qtractor with many fluidsynths, linuxsamplers, 4 klangfalters and other stuff, plus running jamin.

Linux – MOTU UltraLite AVB – Qtractor – http://suedwestlicht.saar.de/

Post Reply