Nithin Sai K J
C++ · mmap · WAL

cpp-db

cpp-db is a page-oriented storage manager written in C++. It coordinates fixed-size pages between disk and an in-memory buffer pool using atomic frame transitions and a write-ahead log that records changes before dirty pages are flushed.

Source code

Atomic frame lifecycle
Buffer frames transition across INVALID → LOADING → RESIDENT → DIRTY → FLUSHING via atomic compare-and-swap operations, while pin counts prevent active pages from being evicted.
Hybrid file I/O
Large database files read through memory-mapped regions for zero-copy access, while smaller segments fall back to positional pread and pwrite calls.
Write-ahead log
Each dirty-page change is appended to the log with its log sequence number, page ID, and changed bytes before the buffer pool flushes it.