LMDB的内部设计有什么特别之处? [英] What is special about internal design of LMDB?
问题描述
在内存B树的某些C ++实现(例如google btree)和LMDB(不考虑LMDB的所有功能,例如事务,隔离,共享访问等)?
What would be the performance difference (reads/writes) between some C++ implementation of in-memory B-Tree (for example google btree) and the LMDB (without taking into consideration all the feacures of LMDB such as transactions, isolation, shared access etc.)?
推荐答案
此 Howard Chu 的> 2014 lmdb设计演示介绍了lmdb
的设计和权衡.
This 2014 lmdb design presentation by its architect Howard Chu covers the design and tradeoffs of lmdb
.
总结:lmdb
是写时复制,自底向上更新,双缓冲,b树,在实现时,只要与其他考虑因素冲突,该实现总是偏向于简化.
To summarize: lmdb
is a copy-on-write, bottom-up updated, double-buffered, b-tree where the implementation always favors simplicity whenever it clashes with other considerations.
聪明的设计选择 使之成为目前性能最高且抗腐败性最高的B树实现之一.
The smart design choices make it one of the highest performance and corruption-resistant B-tree implementations out there.
- 写时复制意味着永远不会覆盖数据,从而避免了许多可能的损坏情况
- 从叶到根的自下而上的更新使根更新等同于提交
- 过去版本的双缓冲仅将后两个根保留在db文件中 避免使用
- 复杂的多级缓存方案-
lmdb
依赖底层操作系统进行缓存 - 与其他数据库相比,整个代码库非常小,避免了CPU缓存丢失
- copy-on-write means that data is never overwritten avoiding many possible corruption scenarios
- bottom-up updates from leaf to root make the root update equivalent to a commit
- double buffering of past versions keeps only the last-two roots in the db file
- complex multi-level caching schemes are avoided -
lmdb
relies on the underlying OS for caching - The whole code base is very small compared to other DBs avoiding CPU cache misses
显然,这些选择意味着lmdb
对诸如以下的复杂场景不友好:
Obviously, these choices mean that lmdb
is not friendly to complex scenarios such as:
- 多版本数据库回滚(仅最后2个可用)
- 长期事务和延迟提交:这导致仅追加行为,并且可能无限扩展数据库文件
- 多个并发编写器:
lmdb
倾向于使用更简单的多个读取器和单个编写器方案
- multi-version DB rollbacks (only last 2 are available)
- long-lived transactions and delayed commits: these lead to append-only behavior and potentially unlimited growth of the db file
- multiple concurrent writers:
lmdb
favors simpler multiple readers and single writer schemes
完整(超过100页)的演示文稿中还有更多内容.以上只是lmdb
精神的总结.
There's much more in the full (over 100 pages) presentation. The above is just a summary of the spirit of lmdb
.
lmdb
在著名的开源项目(例如Open LDAP和Memcached)中用作核心存储引擎,与微基准测试结果.
lmdb
is used as the core storage engine in prominent open source projects such as Open LDAP and Memcached and in both cases speed-ups of orders of magnitude have been observed compared to alternatives as can be seen in micro-benchmark results.
这篇关于LMDB的内部设计有什么特别之处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!