Run the capture thread with real-time priority #116
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usemlock
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...