Module 7 · Dive 7.2
The lazy Reader.
Reads never load a whole volume. A page request faults through the tiers in order — the head cache in ETS, then CubDB on disk, then a segment fetched from Tigris — stopping at the first hit, and the fetched page is cached on the way back so the next read is fast. Read a hot page, a cold one, and a remote one, then flush the cache and watch a hit turn into a fault.
Descend until hit, cache on return
interactiveWhy faulting beats loading
store.design.mdA volume can be far larger than memory, so the Reader treats pages like a working set rather than a file to slurp. The first tier is ETS, an in-process table holding recently-touched pages — a hit here is a memory read and never blocks on the writer (it reads a committed version, not the head being mutated). Miss, and it reads the page from CubDB’s on-disk B-tree; miss there too — the page has aged out locally — and it pulls the segment from Tigris. Either deep hit fills ETS on the return path, so locality pays off: the second read of the same page is an L1 hit. This is the storage ladder from the landing page made concrete for one read — faults travel down, the answer travels up and warms the cache. The writer and reader share the durable tiers but never block each other, which is the whole point of the split.
References & sources
- Echo records
- store.design.mdlazy Reader, L1 ETS → CubDB → segment
- graft.design.mdpage faults, cache-fill
- External
- ETSin-memory page cache
- Cachetiered lookup, fill on miss
- Page cacheworking set vs. whole file