Skip to main content

Module mmap_reader

Module mmap_reader 

Source
Expand description

Memory-mapped WAL segment reader for Event Plane catchup.

Unlike the standard WalReader (which uses sequential read_exact), this reader maps sealed WAL segments into the process address space via mmap. The kernel manages the page cache — no slab allocator memory is pinned, and mmap reads from page cache don’t contend with the Data Plane’s O_DIRECT WAL append path (O_DIRECT bypasses page cache entirely).

Tier progression:

  1. In-memory Arc slabs (hot, zero-copy from ring buffer)
  2. Mmap WAL segment reads (warm, kernel-managed pages)
  3. Shed consumer + cold WAL replay (last resort)

This reader is used in tier 2: when the Event Plane enters WAL Catchup Mode, it mmap’s the relevant sealed segments and iterates records.

Modules§

observability
Module-scoped atomic counters for observing mmap and fadvise behaviour in production. These counters are incremented by the live code paths (open, madvise, fadvise) and may be read from tests or from a metrics scrape.

Structs§

MmapRecordIter
Iterator over records in a mmap’d WAL segment.
MmapWalReader
Memory-mapped WAL segment reader.

Functions§

replay_segments_mmap
Replay WAL segments from a directory using mmap, starting from from_lsn.
replay_segments_mmap_limit
Paginated mmap replay: reads at most max_records from from_lsn.