Skip to main content

Module memory_map

Module memory_map 

Source
Expand description

Persisted locator table, replayed forward from the WAL on open. Record map: which extent holds which memory, persisted at checkpoints.

The engine keeps the whole locator to extent table in memory; every read resolves its locator through it. The table is persisted at checkpoint time and replayed forward from the WAL on open, so a cold open reads no records.

§Anchoring

Each checkpoint that changed the table appends a Checkpoint WAL entry whose payload is a random 16 byte token, then writes the snapshot stamped with the same token, then truncates the WAL to that entry. The table now is the snapshot plus every WAL entry after the entry carrying its token. A snapshot whose token is not in the WAL can never be matched again, because tokens are never reused for a changed table. On any doubt (missing, corrupt, unmatched, inconsistent with the file) open falls back to a scan of the record chain.

Each entry also carries a stamp, a value refreshed on every write to the record, which lets derived caches (mode probes, salience bounds) persist alongside and detect, without loading the record, that it changed since they were captured.

Structs§

MappedMemory
A memory the map knows about: its id, its locator, and its write stamp.

Constants§

MEMORY_MAP_FILE
File name of the persisted record map inside the database directory.