FAQ

Why this website?

There are a lot of materials online on performance optimization. However, knowing where to start could still be quite troublesome, and as a lot of details are involved, the presentation could be a bit boring. This website hopefully provides a good and fun starting point for beginners.

The website serves as an introduction to certain topics regarding performance optimization. It is NOT supposed to be used as a reference on how code should be written.

How accurate is microbenchmark?

There might be a few reasons that you don't want to trust the benchmark result at face value, even if the code is "correct" (if you find any mistake, feel free to send a MR).

One reason is the benchmark result varies a lot on the compiler/hardware/existing software. You always want to run them yourself at the target setup of your application.

Interpreting the result is another headache:

  • It usually does not take into account the performance when it is mixed up with other code, where resources are shared for the whole app. For example, memory alignment could look good in a microbenchmark, but too much aligned memory could lead to increased cache misses due to cache associativity.
  • At smaller scale, some effects might be magnified compared to normal situations. For example, instruction address could cause a large gain/loss in performance in a microbenchmark. As such, you always want to look at the generated assembly, CPU perf counters, etc. to understand the root cause of speed differences.

Should I change my code like the faster example?

No. You should benchmark the whole codebase in realistic workloads. Microbenchmark is not always a reliable shortcut.