Performance scaling is the central challenge of modern computing. We can't make single cores much faster (heat, power limits), so we add more cores. But does 8 cores give you 8× performance? These laws answer when and why not.
The Setup:
You have some computation taking time T
A fraction f of it is inherently serial (cannot be parallelized)
Let's start with the total execution timeT1 on one processor.
Step 1: Break down the work
Serial portion takes: Tserial=f⋅T1
Parallel portion takes: Tparallel=(1−f)⋅T1
Why this step? We're partitioning the total work into two categories based on whether it can be parallelized. The serial fraction f is a proportion, so f⋅T1 gives us the actual time.
Step 2: Time on n processors
With n processors:
Serial part still takesf⋅T1 (cannot be split!)
Parallel part now takes n(1−f)⋅T1 (perfect division)
Why this step? The serial work is fundamentally sequential—throwing more processors at it doesn't help. The parallel work divides evenly (ideal assumption).
Tn=f⋅T1+n(1−f)⋅T1
Step 3: Define speedup
Speedup is the ratio of single-processor time to multi-processor time:
S(n)=TnT1=f⋅T1+n(1−f)⋅T1T1
Why this step? Speedup measures "how much faster." If S(n)=4, you're 4× faster.
Step 4: Simplify
Factor out T1:
S(n)=f+n1−f1
Why this step? The original time cancels out—speedup depends only on the fractionf, not absolute time.
What this means: If even 10% of your code is serial (f=0.1), the best speedup you can ever achieve is 1/0.1=10×, even with a million cores!
Scalability Analysis: Strong scaling (Amdahl) vs weak scaling (Gustafson)
Performance Metrics: Speedup, efficiency, and how to measure them
Recall Explain to a 12-Year-Old
Imagine you and your friends are building a huge LEGO castle. Some parts you can all work on at the same time—one person does the towers, another the walls, another the gate. That's the parallel work. But some parts only one person can do—like reading the instructions out loud or placing the final flag on top. That's the serial work.
Amdahl's Law says: if you're building the exact same castle, adding more friends helps, but only so much. If reading instructions takes 10 minutes and can't be split, then even with 100 friends, you still need those 10 minutes. You can't get infinitely fast!
Gustafson's Law says: if you get more friends, you don't build the same castle faster—you build a BIGGER castle in the same time! With 10 friends, you build a castle 10× more awesome. The instruction-reading still takes 10 minutes, but now you're reading instructions for a mega-castle, so it's worth it.
The lesson: parallelism works best when you grow the problem, not just rush the same small task.
Dekho, yahan sabse important baat samajhne wali ye hai ki jab aap ek kaam ko multiple processors ya cores mein baant te ho, toh unlimited speedup nahi milta. Amdahl's Law bolta hai ki agar aapke program ka kuch hissa serial hai — matlab jo parallel nahi ho sakta, jaise file padhna ya lock lena — toh wahi part aapka bottleneck ban jaata hai. Formula simple hai: S(n) = 1/(f + (1-f)/n), jahan f serial fraction hai. Aur sabse chaunkane wali baat ye hai ki agar sirf 10% code serial hai, toh chahe aap million cores laga do, maximum speedup sirf 10x hi milega, kyun ki S_max = 1/f. Yaani serial part hamesha aapko rok deta hai.
Ab why-it-matters wali baat: aaj kal single core ko zyada fast banana mushkil hai — heat aur power ki dikkat aati hai — isliye industry more cores add karti hai. Lekin more cores ka matlab automatically zyada performance nahi hota. Jaise humara image processing example mein, 95% kaam parallel hone ke baad bhi 10 cores se sirf 6.9x speedup mila, 10x nahi. Isse ek bahut zaroori lesson milta hai: kabhi kabhi serial part ko optimize karna (jaise faster parsing ya better locking) zyada faydemand hota hai bajaye aur cores daalne ke.
Isi wajah se Gustafson's Law ka perspective interesting hai — ye Amdahl ko ulta karke sochta hai. Gustafson kehta hai ki agar aap apne resources badhne ke saath problem ka size bhi badha do (jaise bada dataset ya higher resolution), toh parallelism bohot acche se scale karta hai. Real world mein aksar aisa hi hota hai — jab aapke paas zyada computing power hoti hai, toh aap bade problems solve karne lagte ho. Toh dono laws ek saath aapko decision lene mein madad karte hain ki kab cores badhana worth hai aur kab nahi.