LMDB的内部设计有什么特别之处?

编程入门 行业动态 更新时间:2024-10-25 14:35:10
本文介绍了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的内部设计有什么特别之处?

本文发布于:2023-07-27 03:04:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219971.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   之处   LMDB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!