Ad Space — Top Banner

Cache Hit Ratio Formula

The cache hit ratio formula measures cache effectiveness.
Learn how to calculate hit rate, miss rate, and effective memory access time with examples.

The Formula

Hit Ratio (h) = Cache Hits / Total Memory Accesses

The cache hit ratio measures how often requested data is found in the cache (fast memory) rather than having to be fetched from slower main memory. It is one of the most important metrics in computer architecture and system performance tuning.

Variables

SymbolMeaningUnit
hCache hit ratio0 to 1 (or %)
Miss Rate1 − h (fraction of accesses that miss)0 to 1
t_cCache access time (fast)nanoseconds (ns)
t_mMain memory access time (slow)nanoseconds (ns)
EMATEffective Memory Access Timenanoseconds (ns)

Effective Memory Access Time (EMAT)

EMAT = h × t_c + (1 − h) × (t_c + t_m)

This gives the average time to access memory, considering both cache hits and misses. On a miss, the CPU first checks the cache (t_c), then goes to main memory (t_m), so the miss penalty is t_c + t_m.

Simplified (simultaneous lookup — some architectures):

EMAT = h × t_c + (1 − h) × t_m

Example 1

Cache hit ratio = 90%, cache time = 5 ns, main memory = 100 ns

EMAT = 0.90 × 5 + 0.10 × (5 + 100)

= 4.5 + 10.5

EMAT = 15 ns — 85% faster than always going to main memory (100 ns)

Example 2

Improving hit ratio from 90% to 99%: same cache/memory times

EMAT at 99% = 0.99 × 5 + 0.01 × 105 = 4.95 + 1.05

EMAT = 6.0 ns — 60% faster than 90% hit ratio (15 ns)

Multi-Level Cache (L1, L2, L3)

EMAT = h₁×t₁ + (1−h₁)×h₂×t₂ + (1−h₁)(1−h₂)×h₃×t₃ + ...

Modern CPUs have 3 levels of cache. Each level is checked in order — only on a miss does the CPU proceed to the next level:

  • L1 cache: ~1–4 ns, typically 32–512 KB, hit rate ~85–95%
  • L2 cache: ~4–12 ns, typically 256 KB–4 MB, hit rate ~90–99%
  • L3 cache: ~20–50 ns, typically 8–64 MB, hit rate ~99%+
  • Main RAM: ~60–100 ns
  • SSD: ~100,000 ns (0.1 ms)
  • HDD: ~10,000,000 ns (10 ms)

When to Use This Formula

  • CPU architecture design and cache sizing decisions
  • Database query cache performance analysis
  • Web server caching (CDN hit ratio, reverse proxy cache)
  • Redis / Memcached effectiveness measurement
  • Operating system page cache evaluation

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.