Skip to content
- Dead code elimination
- data packing (reduce struct size - and handle padding)
- memory locality
- temporal locality (avoid accessing the same memory multiple times)
- spatial locality (accessing data sequentially)
- functions inlining
- vectorization SIMD (e.g: SSE, AVX)
- automatic vectorization (with compiler)
- vector extensions (GCC, clang)
- manual vectorization (computer intrinsics)
- memory prefetching
- Loop tiling
- Loop interchange (for sequential access)
- Lookup table for branches missprediction
- Buffering I/O
- multithreading
- false sharing (thread do not share the same value in cache)
perf c2c record ./bin && perf c2c report
- MESI protocol
- Link Time Optimization (optimize all the code from multiples bitcode object) -
-flto options
- downsides: use lot of memory, not parallel, no incremental (fixed with
flto=thin)
- profile guided optimizations
- compile, run and record, and recompile with profiling data
-fprofile-instr-use
- multiple profile can be merged
llvm-profdata merge