Savan Nahar uses mmap to serve reads from two append-only databases. The call makes a file’s bytes accessible through the process’s memory addresses. The key design choice is to map each segment only after the engine has finished writing it.
- The kernel fetches pages as queries touch them. It can discard clean pages under pressure and read them again later.
- S3 holds the durable segments. The engine downloads files to a local SSD cache, and workers mapping the same local file can share its cached pages in RAM.
- The write-ahead log protects data that hasn’t been sealed yet. Hash tables and other memory that queries allocate still need their own budget.
This works because the engine can promise the mapped bytes will stay put. When reviewing a similar design, trace a cold read and check what prevents a file from being truncated while readers still have it mapped.