Laws of Performant Software
Crista’s Five Laws of Performant Software are a checklist from Crista Videira Lopes (2016) for reasoning about program performance before and during optimization.
Why a checklist?
Performance work is easy to misdirect. The laws point at the failure modes that trip people up: picking the wrong battle (language), ignoring small wins, unbounded resources, guessing instead of measuring, and throwing hardware at bad code.
- Programming language ≪ programmer awareness of performance, no language is magic, any mainstream language can be written fast or slow
- Small details matter, formalized as , the butterfly effect, where:
- are two code versions
- is running the code for time
- small code differences produce exponentially larger performance differences
- corr(performance degradation, unbounded resource usage) > 0.9, uncapped threads, caches, and queues eventually exhaust a resource and stall
- Performance improvements = log(controlled experiments), don’t guess, measure
- N × bad ≠ good, no amount of cores or RAM rescues poorly-written code
Law 3 in practice
If your program starts threads, use a thread pool with a fixed size. If it reads input, don’t read entire unbounded lines. Every resource needs a ceiling and a defined overflow behaviour (reject, queue with limit, shed load)