sled

Build Status crates.io documentation

A modern embedded database.

```rust extern crate sled;

let tree = sled::Config::default() .path(path) .cachecapacity(1e9 as usize) // 1gb of cache .usecompression(true) // requires the zstd build feature .flusheveryms(Some(1000)) // flush IO buffers every second .snapshotafterops(100_000); // snapshot the pagetable every 100k ops .tree();

// set and get tree.set(k, v1); assert_eq!(tree.get(&k), Some(v1));

// compare and swap tree.cas(k, Some(v1), Some(v2));

// scans let mut iter = tree.scan(b"a non-present key < k!"); asserteq!(iter.next(), Some((k, v2))); asserteq!(iter.next(), None);

// deletion tree.del(&k); ```

features

warnings

contribution welcome!

goals

  1. beat LSM's on read performance and traditional B+ trees on write performance.
  2. don't use so much electricity. our data structures should play to modern hardware's strengths.
  3. don't surprise users with performance traps.
  4. bring reliability techniques from academia into real-world practice.

architecture

Lock-free tree on a lock-free pagecache on a lock-free log. The pagecache scatters partial page fragments across the log, rather than rewriting entire pages at a time as B+ trees for spinning disks historically have. On page reads, we concurrently scatter-gather reads across the log to materialize the page from its fragments.

The system is largely inspired by the Deuteronomy architecture, and aims to implement the best features from RocksDB as well.

The LockFreeLog and PageCache are usable on their own for implementing your own high-performance stateful systems!

References