profile
- clang -ftime-trace would output one json file, that can generate flame graph
- gcc -ftime-report would output the phase time and percent
speed up
do not change the code
- faster linker lld faster than gnu bsd linker
- PCH(pre-compiled header)
target_precompile_headers(<target> PUBLIC <headers>)
- cache compile result
- ccache
- sccache(cache shareing)
- unity builds
cmake -DCMAKE_UNITY_BUILD=ON
when cmake 3.16+ - LTO (link time optimization)
cmake -DLLVM_ENABLE_LTO=Thin
for clang - PGO(profile guided optimization)
- Post link optimization
- LLVM-BOLT
- LLVM-Propeller
Grab bag
- -fvisibility=hidden
- -fexperimental-new-pass-manager
- distcc
- LTO on your code
- -ftime-trace
bloaty a size profiler for binaries
change the code
- split one large file into many small file , so that is benefit from parallel compiling
- PIMPL
- fwd class instead of include header