How much speed do we gain by using the cache when the cache is used 80% of the…
2013
How much speed do we gain by using the cache when the cache is used 80% of the time? Assume the cache is 20 times faster than the main memory.
- A.
5.27
- B.
2.00
- C.
4.16
- D.
6.09
Attempted by 76 students.
Show answer & explanation
Correct answer: C
Concept
A cache speeds up memory access because most requests are served by the fast cache instead of the slow main memory. If a fraction h of the accesses hit the cache and the remaining (1 − h) go to main memory, the average (effective) access time is EAT = h·Tc + (1 − h)·Tm. The speed gain from using the cache is the time needed WITHOUT it divided by the time needed WITH it:
Speedup = Tm / EAT = Tm / [ h·Tc + (1 − h)·Tm ]
Applying it here
The cache is used 80% of the time, so h = 0.8; and the cache is 20 times faster than main memory, so Tm = 20·Tc. Take Tc = 1 unit, which makes Tm = 20 units.
Effective access time: EAT = 0.8 × 1 + 0.2 × 20.
EAT = 0.8 + 4 = 4.8 units.
Speed gain = Tm / EAT = 20 / 4.8.
Speed gain = 4.166… ≈ 4.16.
Cross-check
The maximum speed gain at an 80% hit ratio happens when the cache is infinitely fast (Tc → 0), and it equals 1 / (1 − h) = 1 / 0.2 = 5. The answer 4.16 lies just under this ceiling of 5, so it is consistent. Any value above 5 is impossible at this hit ratio, and a value close to 2 would require the cache to be only about 2–3 times faster than main memory, not 20 times.