@ardour_fa3cv was asking about what was causing xruns so I presumed he was looking for a way to reduce them, Ardour on Raspberry Pi 4 Model B first impressions and test results
“Update: I compiled and installed raspbian with kernel preemption turned on. Now I can do 256/2/48000 with minimal (zero?) popping. Some xruns still appear in the jack messages log, but I don’t hear them.”
with qdbus you can get to list xruns that could be happening outside ardour,
“/usr/lib/qt5/bin/qdbus org.jackaudio.service /org/jackaudio/Controller org.jackaudio.JackControl.GetXruns”
– is for jackdbus though, I don’t think that would work if running jackd… – you probably can get verbose output I think from where jackd is running…
The term “preemption” is the scheduling-decision the kernel takes – it can be tuned to do preemption various ways, tailored for Desktop, Server or RT – but for RT the kernel needs to be given patches. RT patches are not available for each kernel release, it is only available at certain intervals, so you can only use a kernel tree available at that interval release if you want to use its available RT patches, (the RT patches come in a single .patch.gz file)
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.2/
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/5.2/patch-5.2.21-rt13.patch.gz
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.2.21
I haven’t compiled the latest, but I’ve done so with 5.2.14,
prior to doing patches, the available preemption models lists just 3 preemption models (no rt),
After you apply the rt patches, the make menuconfig now shows two newly available RT preemption models.
What I found was I can significantly reduce x-runs by using the same CFS settings as from avllinux and UbuntuStudio which use the same sched_* parameters,
sched_latency_ns:6000000
sched_migration_cost_ns:500000
sched_min_granularity_ns:750000
sched_wakeup_granularity_ns:1000000
sched_nr_migrate:8
sched_rr_timeslice_ms:100
fwiw I am able to reduce further x-runs even more by applying changes to sched_features …
(i use these at the end of /etc/rc.local – debian)
echo “NO_WAKEUP_PREEMPTION” > /sys/kernel/debug/sched_features
echo “HRTICK” > /sys/kernel/debug/sched_features
echo “DOUBLE_TICK” > /sys/kernel/debug/sched_features
echo “NO_GENTLE_FAIR_SLEEPERS” > /sys/kernel/debug/sched_features
Since rpi’s use an SoC chip I don’t know if these changes make a difference… but these changes make a day and night difference on the systems I use.
(If you’re not using an RT kernel, don’t bother to apply anything other than NO_WAKEUP_PREEMPTION and NO_GENTLE_FAIR_SLEEPERS, as you are likely to stall the machine.)
According to the kernel devs, having sched_wakeup_granularity_ns as 0 is also legitimate. It similarly does the same thing as NO_WAKEUP_PREEMPTION…
I had to tune things multiple times until I was able to mitigate x-runs… Prior occasions I would get “zero” x-runs when not doing any recording (something as simple as a Midi track, just recording midi note values with a usb midi keyboard)… I could do live-tests of digital/midi synths with a usb midi keyboard and never get any x-runs, as soon as I hit the “record”, bam floods of x-runs…
“I compiled and installed raspbian with kernel preemption turned on” << that raises questions because that is 100% related to how the scheduling is applied… though it’s not clear which “preemption” model was recompiled…
Preemption is done at different styles with the linux kernel, … it’s likely too finnicky to talk about on here, but you are changing the scheduler behaviour of the kernel when you recompile it with a different preemption model.
@x42
“In any case, I expect the bottleneck is still USB (I/O and IRQ handling) not scheduling in general.”
ardour_fa3cv brought it up actually and I just added more things to fine-tune the scheduler, which I would of thought he was after… you probably have good reservations about it, but the fact is you don’t say anything to @ardour_fa3cv who was doing exactly that — changing the kernel’s preemption model in general changes the scheduler. And he recompiled a whole kernel just for that, yet you said nothing about it.
I’m only trying to help another user who was already doing something as large as recompiling their kernel and providing settings known to be valid and “safe” from the AvlLinux and UbuntuStudio – and I think(or would of thought) such advice can be encouraged rather than discouraged.
@paul dunno why @x42 said nothing to @ardour_fa3cv about what he told me, when @ardour_fa3cv is doing 100% just that. I don’t know what it is with @x42 , but I did not bring up the topic of scheduling when a user says they completely recompile their kernel with a different preemption model. Be honest @x42 , I’m here to help and you know it. Just tell me if these topics are permitted on this forum because you are lying to me when you try to make it look like I brought up the idea of “scheduling” when a user here recompiles a whole new kernel with a different “scheduling” preemption model. Be honest.
The RT patches do all kinds of things in prioritizing IRQ and RCU things, a user can easily grep through the patch package and see full of commit comments about them. So the “bottleneck” is dealt with by recompiling things, and that is never mentioned… But I never encouraged the topic when it was already strongly indicative to begin with when a user recompiles a kernel’s sheduling preemption model. This is just @x42 trying to make me look stupid again.
and I help pay for your work @x42 – I contribute financially to ardour monthly and I am an owner of mixbus32cc, so show a littlle dam respect.
cheers