simoninns / DomesdayDuplicator

High-speed LaserDisc RF sampler
GNU General Public License v3.0
148 stars 21 forks source link

Run the capture thread with real-time priority #116

Closed atsampson closed 2 years ago

atsampson commented 2 years ago

This uses a couple of techniques common in Linux audio real-time programming: if possible, run the latency-sensitive capture thread with the SCHED_RR scheduling policy so it will preempt other userspace processes, and use mlock to ensure that the disk buffers stay in main memory rather than being paged out.

I tested this on my oldest USB3-capable machine (a Lenovo X220), and it significantly reduces the incidence of test-mode errors when the machine's under deliberately heavy load. On a current machine running a PREEMPT-RT kernel, I ran an 8h test-mode capture without errors while doing large compiles in the background.

This only affects the USB capture side of things - it would be worth thinking about increasing the number of disk buffers as well by default, since the current buffer is only about 3 seconds' worth of capture, and I expect most machines with USB3 can spare a couple of gigs of memory...