I used the RT-tools again to test the latency of the Preempt-RT and the Standard Kernels on the Raspberry Pi 3 Model B and B+.

The results are the following:

**Raspberry 3 Model B+**

Fig. 1 (a): Latency Using Standard Raspbian Kernel (4.14.27-v7+) on Raspberry Pi 3 B+ | Fig. 1 (b): Latency Using Preempt-RT Patched Raspbian Kernel (4.14.27-rt21-v7+) on Raspberry Pi 3 B+ |

**Raspberry 3 Model B**

Fig. 2 (a): Latency Using Standard Raspbian Kernel (4.14.27-v7+) on Raspberry Pi 3 B | Fig. 2 (b): Latency Using Preempt-RT Patched Raspbian Kernel (4.14.27-rt21-v7+) on Raspberry Pi 3 B |

The standard kernel on the model B+ is more irregular: There are more 'samples' between 160us and 400us and the maximal latency is slightly higher (390us (B+) vs 382us (B)). The latency improvement on the Raspberry Pi 3 Model B+ using the Preempt-RT kernel is better (109us (B+) vs 136us (B)).

**N-Queens Problem as Benchmark Test**

The N-Queens Problem/Puzzle is a well-known problem that consists of placing N chess queens on an N × N chessboard so that no two queens attack each other. For example, one possible solution to the N-queens problem for N = 4 is the following:

Fig. 3: N-queens problem example (N = 4). Source: Google Optimization Tools |

As you can see, no two queens are on the same row, column or diagonal. Usually the problem consists to find all possible solutions, rather than one optimal solution.

https://lemariva.com/blog/2018/04/raspberry-pi-the-n-queens-problem-performance-testI wrote a script in Python that calculates the number of all possible solutions. This script can be used as Benchmark for e.g. the Raspberry Pi.

Many people use the N-queens problem to test the performance of a defined solver. But this can be cheated. In my case, the solver (script) is not optimal (I implemented the backtracking way based on this solution), but it works, and it helps me to compare different configurations of the Raspberry Pi (kernel, model B & B+ etc.). I solved the N-queens problem for N=12, in single (ST) and multi-thread (MT) configurations and repeated the tests 45 (ST) / 100 (MT) to check the result variances.

For the following Benchmark tests, I used the following hardware:

* Raspberry Pi 3 Model B

* Raspberry Pi 3 Model B+

Both boards with the following heatsink.

**Preempt-RT vs. Standard Raspbian Kernel Performance**

Fig. 4 (a): Comparison Mean Time to find all Solution on Standard Raspbian Kernel | Fig. 4 (b): Comparison Mean Temperature on Standard Raspbian Kernel| |

Fig. 5 (a): Comparison Mean Time to find all Solution on Preempt-RT Patched Raspbian Kernel | Fig. 5 (b): Comparison Mean Temperature on Preempt-RT Patched Raspbian Kernel| |

The Raspberry Pi 3 Model B+ using standard Raspbian kernel is 12% faster than using Preempt-RT kernel in multi-thread operations. In single-thread operations, this percentage reduces to 11%.

Same relation can be seen on the Model B: The standard Raspbian kernel is 12% in multi-thread configuration while only 9% in single-thread.

The IRQ related with the USB/Network chip interrupts often, this takes about 5%-15% of CPU performance (reported using 'top'). Almost same percentages are obtained on these analysis. Temperature is the main problem, the CPU reaches faster 68°C and reduces its performance.

**Preempt-RT vs. Standard Raspbian Kernel Performance with Network/USB Load**

The USB/Network IRQ interruption reduces the performance of the Preempt-RT kernel up to 12%. To test if its influence is greater if the network/ethernet or USB ports are used, I made the following test: I run the N-queens problem solver in multi-thread configuration and on a separated thread a webserver that received POST requests, and saved these requests (images) on a USB-driver. On my computer, I run a web client and send images in a loop. For...

Read more »