HI,
I’ve been working on a realtime AV performance using Renoise, Processing & SuperCollider on Linux for couple of years now and have never been able to truly get rid of XRUNS, sometimes really badly. I tried everything and today I noticed something interesting.
I followed some of advices in how to setup realtime IRQ and scheduling priority using rtirq (via http://www.rncbc.org/drupal/node/252). There I found some nice diagnostic tools to see what priorities some processes and their threads have.
So essentially highest priority should have the soundcard (firewire in my case), just after rt clock (rtc), and then jack and finally renoise?
I now also realise that on linux Renoise uses FIFO and RoundRobin schedulers (no other audio program seem to use RR scheduler on Linux). While those renoise threads that use FIFO (FF) have a priority of 50, those that use RoundRobin (RR) have priority of 95! Which is above the priority of firewire kernel driver AND realtime clock(?). While I’m not an expert but I’m suspecting that this is what is creating quite heavy glitches in my Linux.
Could somebody please explain a bit if Round Robin scheduled threads with priority of 95 should or shouldn’t interfere with jack and soundcard? I guess it would be helpful in my quest to get rid of glitches on Linux.
here’s some indication on what’s happening:
$ sudo ps -eLo pri,rtprio,cls,pid,nice,cmd | grep -E 'firewire|renoise|jackd|scsynth|rtc|RTPRI' | sort -r
PRI RTPRIO CLS PID NI CMD
135 95 RR 2255 - renoise
135 95 RR 2255 - renoise
130 90 FF 114 - [irq/8-rtc0]
125 85 FF 200 - [irq/20-firewire]
106 66 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
105 65 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
104 64 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
100 60 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
95 55 FF 2938 - scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
95 55 FF 2255 - renoise
90 50 FF 2938 - scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
90 50 FF 2938 - scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
90 50 FF 1443 - [irq/29-nvidia]
41 1 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
41 1 FF 2583 - jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
39 - TS 196 -20 [firewire_ohci]
39 - TS 192 -20 [firewire]
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2938 0 scsynth -u 57110 -a 124 -i 4 -b 1026 -m 900000 -R 0 -C 0 -l 1
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2583 0 jackd -R -P 60 -d firewire -r 44100 -p 128 -n 3
19 - TS 2255 0 renoise
19 - TS 2255 0 renoise
19 - TS 2255 0 renoise
RR = round robin, FF = first in first out, TS = OTHER - the default universal time-sharing scheduler policy used by most processes
$ sudo /etc/init.d/rtirq status
PID CLS RTPRIO NI PRI %CPU STAT COMMAND
114 FF 90 - 130 0.0 S irq/8-rtc0
200 FF 85 - 125 1.0 S irq/20-firewire
491 FF 80 - 120 0.0 S irq/28-snd_hda_
492 FF 80 - 120 0.0 S irq/17-snd_hda_
110 FF 75 - 115 0.0 S irq/16-uhci_hcd
109 FF 74 - 114 0.0 S irq/18-uhci_hcd
108 FF 73 - 113 0.0 S irq/19-uhci_hcd
107 FF 72 - 112 0.0 S irq/23-uhci_hcd
113 FF 70 - 110 0.0 S irq/1-i8042
112 FF 69 - 109 0.0 S irq/12-i8042
38 FF 50 - 90 0.0 S irq/9-acpi
92 FF 50 - 90 0.0 S irq/14-ata_piix
93 FF 50 - 90 0.0 S irq/15-ata_piix
99 FF 50 - 90 0.0 S irq/19-ata_piix
106 FF 50 - 90 0.0 S irq/23-ehci_hcd
423 FF 50 - 90 0.0 S irq/7-parport0
1144 FF 50 - 90 0.0 S irq/27-eth0
1443 FF 50 - 90 0.3 S irq/29-nvidia
3 TS - 0 19 0.0 S ksoftirqd/0
14 TS - 0 19 0.0 S ksoftirqd/1
19 TS - 0 19 0.0 R ksoftirqd/2
24 TS - 0 19 0.0 S ksoftirqd/3
here above you can see there are two Renoise threads that have higher priority than RTC and firewire hardware. does that mean that if Renoise demands CPU cycles and there’s no time left for firewire HW this produces a glitch? or is RR algorhythm here the one that does not make this a priority?
from http://www.cyberciti.biz/faq/howto-set-real-time-scheduling-priority-process/ :
The scheduler is the kernel part that decides which runnable process will be executed by the CPU next. The Linux scheduler offers three different scheduling policies, one for normal processes and two for real-time applications.
- SCHED_OTHER – the default universal time-sharing scheduler policy used by most processes.
- SCHED_FIFO or SCHED_RR – intended for special time-critical applications that need precise control over the way in which runnable processes are selected for execution
So gathering from this RR is pretty realtime (or lowlatency), and could interfere with FF-scheduled threads if it has a higher priority?
I’m using a lowlatency kernel, no fancy window managers with any fancy 3D accelerations (Awesome WM) etc. (it is true however that Processing is using opengl, but that’s actually a separate X server on the same machine - however nvidia IRQ has a very low RT priority of 50, far from firewire and jackd, so it shouldn’t be a problem).
any ideas greatly appreciated!