Skip to content

Commit

Permalink
docs: Add link to C++ optimization guide
Browse files Browse the repository at this point in the history
  • Loading branch information
2b-t committed Jan 18, 2025
1 parent ba85cb2 commit a0678e9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions doc/RealTimeProgramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ One can find a few developer checklists for real-time programming such as [this]

- Select algorithms by a low **worst-case complexity** and not a low average complexity (see also [here](https://www.cs.odu.edu/~zeil/cs361/latest/Public/averagecase/index.html)). Keep in mind though that these latency are derived from asymptotic analysis for a large number of elements and only up to a constant (which can be quite large): Two O(n) algorithms might be very different in terms of computational speed (number of instructions and CPU cycles taken), just their scaling will be similar and similarly a O(n²) algorithm might be faster for small and medium container sizes. Therefore in particular for smaller or fixed size containers it is necessary to **benchmark** the chosen algorithm. For small containers the cache locality and memory allocation of an algorithm will likely be far more important than its asymptotic scaling behavior.
- **Split your code** into parts that have to be **real-time** and a **non real-time** part and make them communicate with lock-free programming techniques
- For optimizing algorithms have a look at Agner Fog's guides on software optimization [here](https://www.agner.org/optimize/), in particular [Optimizing software in C++](https://www.agner.org/optimize/optimizing_cpp.pdf).

- **Set a priority** (nice values) to your real-time thread (see [here](https://medium.com/@chetaniam/a-brief-guide-to-priority-and-nice-values-in-the-linux-ecosystem-fb39e49815e0)). `80` is a good starting point. It is not advised to use too high priorities as this might result in problems with kernel threads:

Expand Down

0 comments on commit a0678e9

Please # to comment.