51 releases (stable)

new 2.9.0 Apr 19, 2025
2.8.0 Mar 30, 2025
2.6.6 Feb 26, 2025
2.5.0-pre.0 Dec 20, 2024
0.2.3 Dec 25, 2023

#107 in Data structures

Download history 329/week @ 2024-12-28 696/week @ 2025-01-04 786/week @ 2025-01-11 592/week @ 2025-01-18 698/week @ 2025-01-25 994/week @ 2025-02-01 1175/week @ 2025-02-08 1451/week @ 2025-02-15 1385/week @ 2025-02-22 997/week @ 2025-03-01 767/week @ 2025-03-08 550/week @ 2025-03-15 1440/week @ 2025-03-22 2013/week @ 2025-03-29 1392/week @ 2025-04-05 1127/week @ 2025-04-12

6,068 downloads per month
Used in 22 crates (2 directly)

MIT/Apache

530KB
12K SLoC

CI docs.rs Crates.io MSRV dependency status

A K.I.S.S. implementation of log-structured merge trees (LSM-trees/LSMTs) in Rust.

This crate only provides a primitive LSM-tree, not a full storage engine. For example, it does not ship with a write-ahead log. You probably want to use https://github.com/fjall-rs/fjall instead.

About

This is the most feature-rich LSM-tree implementation in Rust! It features:

  • Thread-safe BTreeMap-like API
  • 99.9% safe & stable Rust
  • Block-based tables with compression support
  • Range & prefix searching with forward and reverse iteration
  • Size-tiered, (concurrent) Leveled and FIFO compaction
  • Multi-threaded flushing (immutable/sealed memtables)
  • Partitioned block index to reduce memory footprint and keep startup time short [1]
  • Block caching to keep hot data in memory
  • Bloom filters to increase point lookup performance
  • Snapshots (MVCC)
  • Key-value separation (optional) [2]
  • Single deletion tombstones ("weak" deletion)

Keys are limited to 65536 bytes, values are limited to 2^32 bytes. As is normal with any kind of storage engine, larger keys and values have a bigger performance impact.

Feature flags

lz4

Allows using LZ4 compression, powered by lz4_flex.

Disabled by default.

miniz

Allows using DEFLATE/zlib compression, powered by miniz_oxide.

Disabled by default.

bytes

Uses bytes as the underlying Slice type.

Disabled by default.

Stable disk format

The disk format is stable as of 1.0.0.

2.0.0 uses a new disk format and needs a manual format migration.

Future breaking changes will result in a major version bump and a migration path.

Run unit benchmarks

cargo bench --features lz4,miniz

License

All source code is licensed under MIT OR Apache-2.0.

All contributions are to be licensed as MIT OR Apache-2.0.

Footnotes

[1] https://rocksdb.org/blog/2017/05/12/partitioned-index-filter.html

[2] https://github.com/facebook/rocksdb/wiki/BlobDB

Dependencies

~4–13MB
~178K SLoC