Internally LMDB uses
B+ tree data structures. The efficiency of its design and small footprint had the unintended side-effect of providing good write
performance as well. LMDB has an
API similar to
Berkeley DB and
dbm. LMDB treats the computer's memory as a single address space, shared across multiple processes or threads using
shared memory with
copy-on-write semantics (known historically as a
single-level store). Most former modern computing architectures had a 32-bit
memory address space, imposing a hard limit of 4 GB on the size of any database that directly mapped into a single-level store. However, today's 64-bit processors now mostly implement 48-bit address spaces, giving access to 47-bit addresses or 128 TB of database size, making databases using shared memory useful once again in real-world applications. Specific noteworthy technical features of LMDB are: • Its use of
B+ tree. With an LMDB instance being in shared memory and the
B+ tree block size being set to the OS page size, access to an LMDB store is extremely memory efficient. • New data is written without overwriting or moving existing data. This guarantees data integrity and
reliability without requiring transaction logs or cleanup services. • The provision of a unique append-write mode (MDB_APPEND) or between computers of differing
endianness.
Concurrency LMDB employs
multiversion concurrency control (MVCC) and allows multiple threads within multiple processes to coordinate simultaneous access to a database. Readers scale linearly by design. While write transactions are globally serialized via a
mutex, read-only transactions operate in parallel, including in the presence of a write transaction. They are entirely
wait free except for the first read-only transaction on a thread. Each thread reading from a database gains ownership of an element in a shared memory array, which it may update to indicate when it is within a transaction. Writers scan the array to determine the oldest database version the transaction must preserve without requiring direct synchronization with active readers. == Performance ==