After three months of development, the release of the libmdbx 0.10.0 (MDBX) library took place, featuring a high-performance, compact embedded key-value database. The libmdbx code is distributed under the OpenLDAP Public License. libmdbx is a thorough redesign of the LMDB database management system and, according to the developers, surpasses its predecessor in reliability, feature set, and performance. It is claimed that libmdbx is up to 20% faster than LMDB in CRUD scenarios and up to 30% faster if internal checks in libmdbx are disabled to levels comparable to LMDB.
Libmdbx offers ACID compliance, strict change serialization, and non-blocking reads, with linear scaling across CPU cores. Great attention is paid to code quality, stable API operation, testing, and automated checks in libmdbx. It supports auto-compaction, automatic database size management, a single database format for both 32-bit and 64-bit builds, and sampling volume estimation for range queries. A database structure integrity check utility with some recovery options is included. Since 2016, the project has been funded by Positive Technologies, and since 2017, it has been used in its products; the sanctions imposed by the U.S. government against Positive Technologies have no noticeable impact.
The main innovations, improvements, and fixes added since the last release include:
- Bindings for Ruby by Mahlon E. Smith and a trial version of bindings for Python by Noel Kuntze are available, and the bindings for GoLang by Alexey Sharov have been updated.
- For the 'MDBX_WRITEMAP' mode, where the database data is modified directly in RAM, a 'transparent spill' of the modified database pages to disk has been implemented. Now, after each operation is completed, such pages are immediately fully ready for writing to disk, allowing the OS kernel to independently flush the modified pages to disk, and the transaction commit will not require further modification of those pages. As a result, in loaded scenarios with insufficient RAM, the volume of disk operations can be reduced by up to 2 times.
- Implemented the replacement of long-unused shadow copies of modified pages, prioritizing the replacement of pages with large/long values that are, in the overwhelming majority of scenarios, modified only once per transaction. As a result, disk I/O is reduced, thereby increasing performance in scenarios with very large transactions.
- A "smart" page splitting mode has been implemented when inserting keys. Now, when inserting ordered sequences, complete page filling is automatically ensured, while in other cases, a more optimal tree balancing is achieved. Consequently, on average, database pages are filled more optimally, and the B-tree becomes more balanced, positively impacting performance.
- Statistics for page operations have been added, allowing for precise assessment of the cost of modifying operations on the database.
- More than a dozen issues and bugs have been resolved, including: problems with building using MinGW, using `std::filesystem::path` on iOS <= 13.0, building targeting older versions of Windows, etc.
- A total of over 200 changes have been made in 66 files, with approximately 6500 lines added and about 4500 removed.
It is worth highlighting the selection of the Turbo-Geth project (turbo-fork of Go-Ethereum) to use libmdbx as the new storage backend and thank the project team (especially Alexey Sharov, Artem Vorotnikov, and Alexey Akhunov) for their significant help in testing under extreme usage scenarios. In particular, a defect in prefetching/caching management was identified and eliminated, which previously led to performance degradation in complex-to-reproduce scenarios with large databases.
Source: opennet.ru
