Shared item
2 shares
The smallwig theory of optimization
via smallwig by Kevin Bourrillion on April 16, 2008
There are three kinds of optimization.
- Optimization by using a more sensible overall approach.
- Optimization by making the code less weird.
- Optimization by making the code more weird.
To make a type 3 optimization, your burdens are five:- Thou shalt have a reliable benchmark, based on representative inputs.
- Thou shalt demonstrate that your change improves the benchmark.
- Thou shalt successfully argue that this improvement really matters.
- Thou shalt comment the code.
- In nontrivial cases, thou shalt also preserve the clear-but-slow implementation, to use in parity tests with your optimized implementation.
- Your brain is a terrible profiler.
- Hotspot will outsmart you.
- It just doesn't matter, until it matters.
Shared by: