Testing a real-time kernel using PatchBox OS

I re-ran some tests today using the latest PatchBox OS, which features a real-time kernel (4.19.71-rt24-v7l+) and other audio related optimizations. The results were not at all what I was expecting.

First, here is a comparison of device latencies using PatchBox versus Raspbian (kernel 4.19.118-v7l+):

RaspbianHiFiBerry ADC DAC+ Pro48k12851.100 frames (1.0ms)
PatchBoxHiFiBerry ADC DAC+ Pro48k12850-51 frames (1.0ms)
RaspbianHiFiBerry ADC DAC+ Pro48k25650.416 frames (1.0ms)
PatchBoxHiFiBerry ADC DAC+ Pro48k25650-51 frames (1.0ms)
RaspbianHiFiBerry ADC DAC+ Pro96k12850.393 frames (1.0ms)
PatchBoxHiFiBerry ADC DAC+ Pro96k12851-52 frames (1.0ms)
RaspbianHiFiBerry ADC DAC+ Pro96k25650.459 frames (1.0ms)
PatchBoxHiFiBerry ADC DAC+ Pro96k25651-52 frames (1.0ms)
RaspbianSabrent USB48k128451-453 frames (9.4ms)
PatchBoxSabrent USB48k128385-392 frames (8.1ms)
RaspbianSabrent USB48k256498-500 frames (10.4ms)
PatchBoxSabrent USB48k256530-533 frames (11.1ms)
Device loopback latency comparisons, excluding buffers (jack_delay -E)

My first observation is that there appears to be no material difference with latency when using the stock Raspbian kernel versus PatchBox’s real-time kernel with the HiFiBerry: all the measurements are consistently very low at about 51 frames.

Second, and this seems really weird: I got extremely consistent measurements for both the HiFiBerry and Sabrent on Raspbian, but a much wider range of measurements when using PatchBox.

Third, the Sabrent USB device results are inconsistent. The real-time kernel showed a modest advantage for 48k/128 but was worse for 48k/256. This performance degradation also manifests in the full round-trip test results below:

HiFiBerry DAC+ ADC Pro48k1281700-2300 frames (-6ms)
HiFiBerry DAC+ ADC Pro48k2563122-3890 frames (-)
HiFiBerry DAC+ ADC Pro96k1282483-2995 frames (+3ms)
HiFiBerry DAC+ ADC Pro96k2564147-4403 frames (+2ms)
Sabrent USB48k1282300-2900 frames (+2ms)
Sabrent USB48k2563861-4117 frames (+4ms)
Full round-trip loopback over network using JackTrip, including buffer overheads

With the exception of the HiFiBerry at 48k, using the real-time kernel in PatchBox OS increased latency, compared to the latest kernel provided by Raspbian.

All this makes me wonder what may have changed in the Linux kernel between 4.19.71 and 4.19.118? Perhaps there were material enhancements and/or patches made that include significant improvements for audio on Raspberry Pi?

Or, perhaps a real-time kernel is only beneficial when your workloads are taxing the CPU? JackTrip only generates a load of about 20% of a core. The model 4 Pi has four cores. Perhaps the overhead of a real-time kernel makes it a poor choice for this particular use case.

Leave a Reply