Latency of Raspberry Pi 4 on Standard and Real-Time Linux 4.19 Kernel

November 17, 2019

Introduction

This post is an update to my previous post about the same topic for Raspberry Pi 3.

Like in the previous post, I am using the standard kernel which comes with the Raspian image and a similar kernel version with RT patch applied. For Real-Time version, I am using the rpi-4.19.y-rt branch in raspberrypi/linux repository. Similarly for the test, I am using the cyclic test program in Real-Time Linux project.

Cyclic test program measures how much it takes to respond to an interrupt generated by the timer.

Setup

Both experiments below is run on a Raspberry Pi 4.

For the standard linux kernel, I am using the Raspian image and did an upgrade which resulted the kernel version 4.19.75 at the time of writing this post.

For the real-time linux kernel, I cloned rpi-4.19.y-rt branch in raspberrypi/linux repository. At the time of writing this post, this resulted kernel version 4.19.71-rt24-v71+. Here is a post summarizing steps to build the kernel.

For the cyclic test program, I am using the rt-tests-1.5.tar.gz package. I have built the tool with make NUMA=0.

The plots below are generated with gnuplot, using the mklatencyplot script of OSADL. The cyclic test is run with the following parameters:

cyclictest -l100000000 -m -S -p90 -i200 -h400 -q

A single run of this test takes around than 5 hours.

In the previous article, I used no additional load in the system. For this post, I made the experiment with a cpu load generated with stress-ng. I use stress-ng with these arguments: -c 0 -q and run the stressors in low priority with nice -19.

Test Result 1 - Standard Kernel

Latency plot generated on Raspberry Pi 4 running 4.19.75

Latency plot generated on Raspberry Pi 4 running 4.19.75

Test Result 2 - Real-Time Kernel

Latency plot generated on Raspberry Pi 4 running 4.19.71-rt24

Latency plot generated on Raspberry Pi 4 running 4.19.71-rt24

Conclusion

Similar to Raspberry Pi 3 and my previous experiment, Raspberry Pi 4 performs similarly, having lower average latency numbers with Real-Time kernel. Comparing to the previous post, the average latency is higher here, and obviously the reason for this is the load generated by stress-ng. This shows, in order to get a better result, it is important to do such experiments with a reasonably similar load that one is expecting.