Cache Hit Rate and Miss Rate
What You'll Learn
You'll learn to calculate hit rate and miss rate as percentages and understand how they measure cache effectiveness.
Understanding Hit Rate and Miss Rate
When your CPU accesses the cache many times, some lookups succeed (hits) and some fail (misses). Hit rate and miss rate turn these raw counts into meaningful percentages that tell you how well your cache is performing.
Hit Rate = (Number of Hits / Total Accesses) × 100%
Miss Rate = (Number of Misses / Total Accesses) × 100%
These two metrics are complementary: Hit Rate + Miss Rate = 100%
Why This Matters
Think of a cache like a student's backpack. If a student can find 9 out of 10 needed items in their backpack without walking back to their locker, their "hit rate" is 90%. The remaining 10% represents trips back to the locker (the slower main memory).
Example Calculation
Suppose your program makes 1,000 memory accesses:
- 850 are cache hits
- 150 are cache misses
Hit Rate = (850 / 1,000) × 100% = 85%
Miss Rate = (150 / 1,000) × 100% = 15%
Notice: 85% + 15% = 100% ✓
The Relationship
A higher hit rate means better cache performance. If you improve locality of reference or increase cache size, hit rate goes up and miss rate goes down. These percentages directly impact effective access time: more hits mean faster average memory access.
Key Takeaway: Hit rate and miss rate express cache effectiveness as percentages—together they always sum to 100%, with higher hit rates indicating better performance.