A detailed discussion of branch prediction and performance - because in that industry:
"For low-latency systems, a branch miss rate over 1% should raise alarms, and sub-0.5% is ideal for ultra-low-latency paths." 😮 #cpp#cplusplus#performance
https://t.co/9bcNrhRQiX
C++ Insights - Episode 57: More performance thanks to more implicit moves in C++20
In this episode, you learn about a change in the standard that can give you more performance, thanks to the implicit move.
https://t.co/7CI4Z3Y3KS
#cppinsights#cpp
Redis is data structure store that can be used as a database, cache, and message broker. It is used by a wide range of major corporations. Recently, Redis has adopted our library (fast_float) and they report a substantial performance boost (30%).
"Optimizing compilers may turn your conventional code into a table lookup. For example, a switch-case is sometimes compiled to a small table ... what appears like a branch (if-else) might be compiled to conditional move instructions or even to a table.
- as discussed in the book
There are also some new text features like dynamic font support with variable axes (e.g. wght, wdth and ital in the image below). #Qt6_7
https://t.co/jhD9vu6rgK
More of the musl+alpine story: the allocators (a long time favourites of mine, BTW...) ->
"It is known that some memory allocation patterns lead to bad performance with the new hardened malloc. However, the security benefits ... to some extent justifies the performance costs"
"C++ templ library for high perf. SIMD based sorting routines for built-in integers, floats... and custom defined C++ objects... accelerated using AVX-512/AVX2 when available ... library auto picks the best version depending on the processor it is run on"
https://t.co/tNZaX2EzAF
"Toward the end of last year Intel quietly made available x86-simd-sort via their GitHub account. It's a C++ header file library for high performance SIMD sorting though in its current form is just focused on an AVX-512 quicksort implementation."
Rolling your own fast matrix multiplication: loop order and vectorization
If you must multiply matrices, you should use dedicated libraries. However, we sometimes need to roll our own code. In C++, you can quickly write your own Matrix template:
How do you implement a matrix multiplication? A matrix multiplication is a sequence of three loops. If you do not want to get fancy, you have therefore six possibilities:
If you use an optimizing compiler and you tell it to compile specifically for your processor, you should get some fast code, at least in some instances. Which order is best?
The exact result depends on your data type (double, float, int), on the size of the matrices, on your compiler and your hardware. I wrote a benchmark where I use 100 by 100 matrices containing double values. I use GCC 12 (with full optimization -O3) and an Intel Ice Lake processor. I tell the compiler to optimize for the exact processor I have thus I expect that it will use advanced AVX-512 instructions when possible.
The net result in my experiment is that the best ordering is ijk or ikj. That is, the textbook order (ijk) is one of the best. The worst ordering is jik.
If you were to compute manually and naively the matrix multiplications, you would need to do 100 times 100 times 100 multiplications, so 1 million multiplications and 1 million additions. Interestingly, the best orderings (ikj and ijk) use roughly a quarter of a million of instructions to load the data, do the multiplications, the additions and storing the data.
@lemire If you have good performance oriented architecture design, you have less hot spots to optimize. If not, then you run into death by thousand cuts problem. After fixing a few critical issues, everything starts to look like a hotspot, so you have to rewrite everything.
"And that explain why companies do full rewrites of their code for performance: the effort needed to squeeze more performance from the existing code becomes too much and a __complete rewrite is cheaper__."