Here’s the 9th follow-up post in my 10 Habits of Great Server Performance Tuners series. This one focuses on the ninth habit: Don’t Break the Law.
Amdahl’s Law, I mean. Amdahl’s Law tells you how much improvement you can reasonably expect from tuning a part of your system. It is often used in the context of software optimization and parallelization. Basically, what it says is that the potential improvement (speedup) you will get from applying an optimization with a speedup of X to a fraction F of your system is equal to 1/((1-F) + F/X). More generally, the speedup you will get depends on how much of your system the optimization affects as well as how good the optimization is.
For example, say you think you can speed up a function that takes 25% of your application’s execution time. If you can speed it up by 2x, then the potential speedup of your whole application, according to Amdahl’s Law, is 1/((1-.25) + .25/2) or a 1.14x speedup. Knowing something like this means you can evaluate which is more important: a 2x optimization affecting 25% of your code or a 4x optimization affecting 10%. (It’s the 25% one.)
Amdahl’s Law can also be used in other situations, such as estimating the potential speedup from parallelization or evaluating system tuning changes. It can be tricky in certain cases, such as when there are overlapping or dependent parts of the system. So use your intuition as well. However, in general using this law can help you to focus on making the common usage case faster for your system.
Once you have a good understanding of Amdahl’s Law, you may want to check out Gustafson’s Law and Little’s Law as well. All are commonly used in performance optimization. Being armed with the knowledge of these theoretical basics can help you to sniff out suspicious performance results or conclusions, as Neil J Gunther humorously wrote about here.
So stay out of trouble with the law (both the ones I mentioned and the legal kind!), and look for my post on the last habit next month.