Skip to content
About
Main content

Warming and prefetch are two mechanisms, not one

When does a prefetch pay, and how fast can a cold cache be ramped without overwhelming the origin?

They are often grouped together. They share only the direction of the data movement.

Prefetch: speculation on the read path

Prefetch means fetching an item before anyone asks, hoping it will be asked for. Its economics include a cost people leave out. The value of a , and the accuracy P(hit) it needs to pay, are

what a hit on the prefetched entry saves
cost of the speculative fetch
value lost from the entry it displaces

where S is the saving if it hits, C_fetch is the cost of fetching, and C_evict is the cost of the entry it pushed out.

A wrong prefetch costs twice: the bandwidth, and the useful entry that it displaced. C_evict is the marginal value of the displaced entry. That is the slope of the from What makes data cacheable (the curve of miss rate against size). So the prefetch accuracy threshold is set by the gradient of your miss-ratio curve:

  • On a plateau (a flat part), eviction costs almost nothing, so aggressive prefetch is nearly free.
  • Just past a cliff (a steep drop), which is where a well-sized cache should sit, a wrong prefetch is expensive.

This leads to a result that is surprising and correct: It explains why real prefetchers limit themselves to patterns with near-certain continuation (detecting sequential reads, fixed strides) and not anything speculative. Only near-certainty clears the threshold once C_evict is counted. A second reason for caution: prefetch uses the same bandwidth that real (demand) misses need. Aggressive prefetch can cause incast, a pile-up of many responses arriving at one receiver at once, on your own system.

Warming: survivability, not latency

Warming means filling a cache in bulk when no request is waiting. Its purpose is not lower . It is survivability. It exists to prevent the cold-cache collapse that the leverage ratio predicts: at h = 0.95 the origin is sized for one twentieth of the load, so sending full traffic to an empty cache gives the origin 20 times its capacity.

That makes the ramp a control problem with a set-point you can calculate. Admit traffic at a rate λ(t) such that

the hit rate at time t, read from the miss-ratio curve as the cache fills
Data table
Traffic the origin can absorb, by hit rate (origin 1,500 reads/s)
Hit rate as the cache fillsTraffic you may admit (per second)
01.5K
0.0121.52K
0.0251.54K
0.0371.56K
0.0491.58K
0.0611.6K
0.0741.62K
0.0861.64K
0.0981.66K
0.111.69K
0.1231.71K
0.1351.73K
0.1471.76K
0.1591.78K
0.1711.81K
0.1841.84K
0.1961.87K
0.2081.89K
0.2211.92K
0.2331.96K
0.2451.99K
0.2572.02K
0.2692.05K
0.2822.09K
0.2942.12K
0.3062.16K
0.3192.2K
0.3312.24K
0.3432.28K
0.3552.33K
0.3672.37K
0.382.42K
0.3922.47K
0.4042.52K
0.4162.57K
0.4292.63K
0.4412.68K
0.4532.74K
0.4662.81K
0.4782.87K
0.492.94K
0.5023.01K
0.5143.09K
0.5273.17K
0.5393.25K
0.5513.34K
0.5643.44K
0.5763.54K
0.5883.64K
0.63.75K
0.6133.87K
0.6254K
0.6374.13K
0.6494.28K
0.6614.43K
0.6744.6K
0.6864.78K
0.6984.97K
0.715.18K
0.7235.41K
0.7355.66K
0.7475.93K
0.7596.24K
0.7726.57K
0.7846.94K
0.7967.36K
0.8087.83K
0.8218.37K
0.8338.98K
0.8459.69K
0.85710.5K
0.8711.5K
0.88212.7K
0.89414.2K
0.90616K
0.91918.5K
0.93121.7K
0.94326.4K
0.95633.7K
0.96846.5K
0.9875K

where h(t) is the at time t, read from the miss-ratio curve as the cache fills.

The ramp rate follows from the origin's spare capacity and the curve. It does not follow from a fixed timer, which is how ramps are almost always built, and why warm-ups either take far too long or protect nothing.

There are four mechanisms, and they are not equivalent:

MechanismHow it worksWeakness
Top-K replay from the access logreplay the most popular keysfills with yesterday's popularity; wrong when popularity drifts
and restore of cache contentssave the cache before a restart, reload afterbest choice when the substrate allows it: it keeps the real
Shadow trafficcopy live traffic to the new cacheaccurate, but doubles origin load at the worst moment
Gradual traffic rampsend a growing share of real trafficthe only self-tuning one: it fills the cache with exactly the distribution about to be requested

Notice a coupling back to What makes data cacheable: every warming strategy except the ramp needs measured popularity. You cannot warm well without the instrumentation of What makes data cacheable, so the measurement work is a prerequisite for warming too, not only for sizing.

Compression: Prefetch is speculation priced against the slope of the miss-ratio curve, so a well-sized cache prefetches less. Warming is a survivability controller whose ramp rate is set by origin spare capacity. Only the traffic ramp is self-tuning.