Definition · Working set and page-cache hit rateThe page cache holds C pages of a dataset of N pages in memory. Under Zipf popularity with exponent s, the hit rate is h = H(C,s)/H(N,s), where H(n,s) is the generalised harmonic number Σ 1/iˢ over i = 1…n.
The disk IOPS the workload leaves is (1 − h) × reads. At s = 0 the formula collapses to h = C/N, and every page is equally likely to be wanted.
Both sizes have to be converted into pages before anything else happens. At an 8 kB page a 500 GB dataset is 62 500 000 pages and 64 GB of memory is 8 000 000 of them, so C/N = 12.80%. The formula takes counts, not bytes, and a units error here moves the answer more than the skew does.
page 8 kB dataset 500 GB → N = 62 500 000 pages
memory 64 GB → C = 8 000 000 pages C/N = 12.80%
s = 1 h = H(8 000 000, 1) / H(62 500 000, 1) ≈ 88.905% rounded
disk IOPS = (1 − 0.88905) × 20 000 ≈ 2 219 a second
s = 0 h = C/N = 16/125 = 12.800% exact
disk IOPS = (1 − 0.128) × 20 000 = 17 440 a second
The two rows are the lesson. The same memory holding the same share of the same data serves about 88.9% of the reads when popularity is skewed and 12.8% when it is not, and the difference at the disk is a factor of nearly eight. Skew is not a detail of the workload; it is the reason the page cache exists.
What each doubling of memory buys
Hold the dataset and the skew and walk the memory up by factors of two. From a sixty-fourth of the data to a half, the hit rate goes 77.553%, 81.294%, 85.036%, 88.777%, 92.518%, 96.259% — about 3.74 points every time. That is what H(C,1) growing like the logarithm of C looks like: equal multiples of memory buy equal absolute improvements.
Example · Diminishing returns, in the unit the disk cares aboutThe residual IOPS on those same six rows are 4 489, 3 741, 2 993, 2 245, 1 496 and 748. Each doubling removes about 748 IOPS — the same amount every time, not the same fraction. So the first doubling and the last one are worth the same to the disk, and the memory to buy them is thirty-two times more expensive on the last.
The hit rate on this page is rounded and the lab says so on its face. Past N = 40 pages the exact harmonic number is neither computable in a redraw nor readable when printed — its denominator grows far faster than the page — so h comes from a floating-point approximation to H(n,s). The lab prints the exact fraction at N = 40, C = 4 alongside, so the machinery producing the approximation is visible rather than asserted. At s = 0 the formula is C/N and stays exact at any size.
And the model is Zipf, which is a description of many real workloads and a description of none of them exactly. s is measured from a trace, not chosen; a real page cache also does read-ahead, which converts some misses into sequential reads that the IOPS figure treats too harshly, and holds dirty pages, which occupy C without serving reads. The arithmetic is the right first estimate and it is not a measurement.