12.5 Amdahl’s Law and Scaling Limits
Amdahl’s law describes the speedup from parallelization. It models how much of your code can run in parallel and how much must run serially. The serial fraction sets a ceiling on speedup. In practice, four other limits bite before Amdahl does: contention, synchronization cost, memory bandwidth, and load imbalance. Amdahl’s law sets the ceiling, and those four explain why real programs stop short of it.
12.5.1 The mathematical model
Amdahl’s law says the maximum speedup is:
Speedup(N) = 1 / (f + (1 - f) / N)where f is the serial fraction (0 to 1) and N is the number of workers (cores or threads).
The serial fraction f includes all code that cannot be parallelized. As N approaches infinity:
Speedup(∞) = 1 / fThe serial fraction limits the ceiling. If 10 percent of your code is serial, maximum speedup is 10x no matter how many cores you add.
12.5.2 Worked arithmetic: serial fraction of 0.2
Assume your code is 80 percent parallelizable and 20 percent serial:
N = 2: Speedup = 1 / (0.2 + 0.8/2) = 1 / (0.2 + 0.4) = 1.67x
N = 4: Speedup = 1 / (0.2 + 0.8/4) = 1 / (0.2 + 0.2) = 2.5x
N = 8: Speedup = 1 / (0.2 + 0.8/8) = 1 / (0.2 + 0.1) = 3.3x
N = 16: Speedup = 1 / (0.2 + 0.8/16) = 1 / (0.2 + 0.05) = 4.0x
N = 32: Speedup = 1 / (0.2 + 0.8/32) = 1 / (0.2 + 0.025) = 4.4x
N = ∞: Speedup approaches 1 / 0.2 = 5xAt N = 32, you achieve 4.4x speedup with 32 workers. Parallel efficiency is 4.4 ÷ 32 = 14 percent: on average each worker does 14 percent of what an ideal worker would.
Returns diminish fast beyond 16 workers. Going from 16 to 32 workers raised the speedup from 4.0x to 4.4x, so the last 16 workers added 0.4x between them, and the serial fraction leaves 86 percent of the workers’ capacity unused.
12.5.3 Identifying the serial fraction
The serial fraction includes all overhead and necessary serial work:
- Startup cost: initializing workers, loading packages, allocating memory.
- Synchronization: locking, waiting for all workers to finish.
- Merge: combining results from workers.
- Algorithm necessity: parts of the algorithm that cannot parallelize, like certain reductions or dependencies.
Measure the serial fraction empirically. Run your parallel code with increasing worker counts. Plot speedup against worker count. The curve will flatten. The flat part is the serial fraction ceiling.
If speedup reaches 5.3x at 8 workers and tops out at 10x at 32 workers, solve for f using the larger measurement:
10 = 1 / (f + (1 - f) / 32)
0.1 = f + (1 - f) / 32
0.1 = f + 0.03125 - 0.03125f
0.1 - 0.03125 = f - 0.03125f
0.06875 = 0.96875f
f = 0.071 = 7.1 percentYour serial fraction is roughly 7 percent.
12.5.4 Practical limits that bite before Amdahl
Amdahl’s law assumes perfect parallelization beyond the serial fraction. In practice, four limits prevent this.
Contention
When two workers compete for the same resource, one stalls. On a 64-core machine, a shared lock becomes a bottleneck. Fifty cores wait for the one core holding the lock. Contention grows with worker count. A small explicit serial fraction can hide a large contention cost.
A system with no explicit serial section can still behave as if it had one. While one worker holds a contended lock the others wait, and every handoff moves the lock’s cache line from one core to another, so the effective serial fraction can be larger than the code suggests.
Locks that are not contended, with one core at a time, scale well. Locks that are contended, with many cores competing, scale poorly. The cost is not linear with core count. It grows sharply as competition increases.
Synchronization cost
Communication between workers has overhead. Sending a message to another worker is not free. On a shared-memory system with threads, the cost is lower than on a distributed system. But it is nonzero. If the serial fraction includes synchronization, it grows with worker count as message costs accumulate.
A barrier synchronization waits for all workers to reach a point. With 2 workers, the wait is short. With 64 workers, the cost grows. One slow worker delays all others.
Memory bandwidth
A task that reads or writes memory can saturate the available bandwidth to main memory. See caches and bandwidth for details. With bandwidth saturated, adding more workers does not help. All workers compete for the same narrow pipe, and saturated bandwidth acts like a serial fraction.
A machine with 8 cores and 76 GB per second bandwidth can run memory-bound code on 3 or 4 cores before bandwidth saturates. Adding cores 5 through 8 does not improve throughput. The effective serial fraction is the time others wait for memory.
Load imbalance
If workers do not finish at the same time, some sit idle waiting for slow workers. A parallel step takes as long as the slowest worker. Imbalance grows with worker count: the more workers there are, the more likely it is that at least one of them draws a slow task and holds up the whole step.
Dynamic task scheduling (work stealing) helps. See work stealing for how this works. Static scheduling of fixed-size chunks leads to load imbalance at high core counts.
12.5.5 Failure modes
A developer reads Amdahl’s law and calculates that a 90-percent-parallel task can achieve 10x speedup with infinite workers. The developer builds a system with 64 workers. The system achieves 6x speedup. The developer thinks the implementation is flawed.
Amdahl’s law itself already predicts only 8.8x at 64 workers, since 1 / (0.1 + 0.9/64) = 8.8. The rest of the gap comes from what the formula leaves out: it assumes no contention, synchronization cost, or bandwidth limits, and a real 90-percent-parallel task at scale meets all three.
Amdahl’s law only rises and flattens toward its ceiling. A real system often peaks and then falls, because contention, synchronization and bandwidth costs grow with each added worker.
The declining curve above is illustrative. The 90 percent, 64 worker and 6x figures come from the scenario in this section, not from a measurement in this repository, and the shape of the real-system curve past its peak is drawn by hand.
A data scientist reports that a parallel job achieved 8x speedup with 8 cores. The claim needs three facts before it means much: whether the 8 were physical cores or SMT siblings, what the single-worker baseline was, and whether memory bandwidth was already saturated at fewer workers.
12.5.6 Scaling measurement and reporting
Measure speedup as worker count increases. Stop when speedup plateaus. That plateau is the practical limit.
See speedup and scaling for how to measure speedup correctly and report it honestly. That page covers baseline selection, strong versus weak scaling, and the efficiency frontier.
An honest scaling report includes:
- Physical core count.
- The problem size.
- The single-worker baseline and multi-worker times.
- The calculated speedup and parallel efficiency.
- When efficiency plateaus.
- Whether you see signs of contention, bandwidth saturation, or imbalance.
- The estimated serial fraction (solve for f from your speedup curve).
Further reading
- Amdahl, G. M. (1967). “Validity of the Single Processor Approach to Achieving Large Scale Computing Capabilities”. AFIPS Spring Joint Computer Conference, 483-485. doi:10.1145/1465482.1465560 <https://doi.org/10.1145/1465482.1465560>.
- Gustafson, J. L. (1988). “Reevaluating Amdahl’s Law”. Communications of the ACM 31(5), 532-533. doi:10.1145/42411.42415 <https://doi.org/10.1145/42411.42415>. Introduces scaled speedup, the basis of weak scaling.
- Gropp, W., Lusk, E. and Skjellum, A. (2014). Using MPI: Portable Parallel Programming with the Message-Passing Interface, 3rd edition <https://mitpress.mit.edu/9780262527392/using-mpi/>. MIT Press.