What does Cache Hit Ratios and the Che Approximation conclude, in numbers, about “Eastern and Western Classics: the Nine-Year Reserve of the Royal Regulations and Belady's Optimal Replacement”?
Answer: Chapter 7 examines "a state without a reserve of nine years is said to be short" from the Royal Regulations of the Book of Rites alongside Belady's optimal replacement of 1966, uses a granary model to show that spoilage decides whether a nine-year reserve is reachable, and confirms optimal replacement by exhaustive search.
Scope of the numbers: Under Zipf requests the hit ratio of a least-recently-used (LRU) cache grows slowly with capacity: with illustrative parameters, a hundred-and-twenty-eight-fold increase in capacity raises the hit ratio only 6.80 times. Chapter 4 derives the optimal capacity from slope and cost, 4187 slots or 0.2094 of the catalogue under illustrative parameters, with a flat cost curve around the optimum.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python only
| Reserve cap S (years of need) vs shortage, 30-year horizon | ||||
| spoil | S | P(any shortage) | shortage yrs | spoilage/yr |
| 0.02 | 0 | 0.9929 | 4.502 | 0.0000 |
| 0.02 | 1 | 0.6690 | 1.447 | 0.0154 |
| 0.02 | 3 | 0.0891 | 0.157 | 0.0498 |
| 0.02 | 6 | 0.0088 | 0.017 | 0.1003 |
| 0.02 | 9 | 0.0069 | 0.014 | 0.1265 |
| 0.05 | 0 | 0.9929 | 4.502 | 0.0000 |
| 0.05 | 1 | 0.7524 | 1.733 | 0.0379 |
| 0.05 | 3 | 0.1593 | 0.291 | 0.1131 |
| 0.05 | 6 | 0.0827 | 0.151 | 0.1621 |
| 0.05 | 9 | 0.0827 | 0.151 | 0.1622 |
| ceiling surplus / spoilage at s = 0.02: 16.67 years | ||||
| ceiling surplus / spoilage at s = 0.05: 6.67 years |
Show the full program
# Chapter 7. p71: the Wangzhi reserve rule as a testable stock model.
# Model: a state eats 1 unit of grain a year. A normal harvest yields
# 4/3 (the text's "three years of farming leave one year of food"), a
# bad year (probability 0.15) yields 1/5. Stored grain loses a share s
# each year to spoilage, and the granary holds at most S years. After
# 60 unscored years that let the stock settle, a 30-year horizon (the
# text's "thirty-year average") is scored: we count years in which
# stock plus harvest cannot cover need. 20000 seeded histories per
# cell. Yields, bad-year odds and spoilage are illustrative.
import math
import random
GOOD, BAD, PBAD, BURN, YEARS, TRIALS = 4 / 3, 1 / 5, 0.15, 60, 30, 20000
def history(rng, cap, spoil):
stock, short, lost = 0.0, 0, []
for y in range(BURN + YEARS):
crop = BAD if rng.random() < PBAD else GOOD
if y >= BURN:
lost.append(stock * spoil)
stock = stock * (1 - spoil) + crop - 1.0
if stock < 0:
if y >= BURN:
short += 1
stock = 0.0
stock = min(stock, cap)
return short, math.fsum(lost) / YEARS
if __name__ == "__main__":
print("Reserve cap S (years of need) vs shortage, 30-year horizon")
print(" spoil S P(any shortage) shortage yrs spoilage/yr")
for spoil in (0.02, 0.05):
for cap in (0, 1, 3, 6, 9):
rng = random.Random(20261113)
any_s, yrs, loss = 0, [], []
for _ in range(TRIALS):
s, l = history(rng, cap, spoil)
if s:
any_s += 1
yrs.append(s)
loss.append(l)
print(" {:.2f} {:2d} {:.4f} {:.3f}"
" {:.4f}".format(
spoil, cap, any_s / TRIALS,
math.fsum(yrs) / TRIALS, math.fsum(loss) / TRIALS))
for spoil in (0.02, 0.05):
print("ceiling surplus / spoilage at s = {:.2f}: {:.2f} years"
.format(spoil, (GOOD - 1) / spoil))Single source and citation
Fan, Y. (2026). Cache Hit Ratios and the Che Approximation: Optimal Capacity for Caching Computed Charts (Version 1.0.0), Chapter 7: Eastern and Western Classics: the Nine-Year Reserve of the Royal Regulations and Belady's Optimal Replacement. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-327 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026327,
author = {Fan, Yafu},
title = {Cache Hit Ratios and the Che Approximation: Optimal Capacity for Caching Computed Charts},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · The Doubling Illusion: Hit-Ratio Curves under Zipf Requests
- Chapter 2 · The Characteristic Time: Solving the Che Approximation by Bisection, and How Accurate It Is
- Chapter 3 · Belady's Bound: Optimal Replacement, the Static Bound and the Capacity Price of LRU
- Chapter 4 · Marginal Returns: the Slope of the Capacity Curve and the Cost-Optimal Boundary
- Chapter 5 · Non-Stationary Requests: Popularity Drift, Frozen Lists and Cold Starts
- Chapter 6 · Partitions and Tiers: the Same Slots, Arranged Differently
- Chapter 8 · Closing the Loop: Read-Only Capacity Planning for a Toll Booth's Chart-Result Cache