Lightning Memory-Mapped Database Manager (LMDB) 1.0
6 hours ago
- #Embedded Systems
- #Database
- #High Performance
- LMDB is a Btree-based embedded database management library with a simplified BerkeleyDB-like API.
- It uses memory-mapped files for direct data access, eliminating the need for malloc or memcpy during fetches, resulting in high performance and simplicity.
- The database is fully transactional with ACID semantics, thread-aware, and supports concurrent read/write access across multiple processes and threads.
- Data pages employ copy-on-write, preventing overwrites and ensuring corruption resistance without special recovery after system crashes.
- Writes are serialized to avoid deadlocks, while readers operate without locks due to multi-versioning, allowing non-blocking read/write concurrency.
- Unlike write-ahead logs or append-only databases, LMDB requires no maintenance like checkpointing, as it reuses free pages to prevent unbounded file growth.
- Memory maps can be read-only (for corruption immunity) or read-write (for higher write performance, but with risk from buggy application code).
- Stale reader transactions or broken lockfiles can cause issues; fixes include using mdb_reader_check and handling semaphore ownership on BSD systems.