A Rust implementation of RocksDB, a high-performance embedded key-value store originally developed by Facebook.
Note: This project was created using Claude Code. See all prompts used to create this project - you can use them as a reference to create your own project!
RucksDB is designed as an educational project to demonstrate database internals and Rust best practices:
- Custom implementations for learning (e.g., LRU cache using HashMap + doubly-linked list)
- Rust 2024 Edition with nightly features for modern idioms
- Comprehensive documentation explaining architectural decisions
- Clear code structure prioritizing readability over micro-optimizations
- Rust Nightly: This project uses Rust 2024 edition and nightly features
- Automatically configured via
rust-toolchain.toml
LSM-Tree implementation with performance optimizations:
- Core Data Types:
Status,Slicewith zero-copy semantics - MemTable: Lock-free SkipList with MVCC support
- Basic Operations: Put, Get, Delete with sequence numbers
- Write Ahead Log (WAL): Crash recovery and durability
- SSTable: Persistent sorted string tables with block-based storage
- Compaction: Multi-level compaction with size-based triggering
- Version Management: MVCC with multiple versions
- Custom LRU Cache: Educational implementation (HashMap + doubly-linked list)
- Bloom Filters: Reduce unnecessary disk I/O (240x speedup for non-existent keys)
- Compression: Snappy and LZ4 support
- Immutable MemTable: Non-blocking writes during flush
LSM-Tree design with educational focus:
- Write path: WAL → MemTable → Immutable MemTable → SSTable
- Read path: MemTable → Immutable MemTable → L0 → L1..Ln SSTables
- Compaction: Size-based triggering with configurable thresholds
- See BENCHMARKING.md and BENCHMARK_RESULTS.md for performance characteristics
use rucksdb::{DB, DBOptions, ReadOptions, WriteOptions, Slice};
fn main() {
let db = DB::open("my_db", DBOptions::default()).unwrap();
// Write
db.put(&WriteOptions::default(),
Slice::from("key"),
Slice::from("value")).unwrap();
// Read
let value = db.get(&ReadOptions::default(), &Slice::from("key")).unwrap();
println!("Value: {:?}", value);
// Delete
db.delete(&WriteOptions::default(), Slice::from("key")).unwrap();
}# Run all tests (92 unit tests + integration tests)
just test
# Run benchmarks
just bench
# Run pre-commit checks (format, clippy, tests)
just pre-commit
# See all available commands
just- Single-threaded write: 330K ops/sec (100B), 134K ops/sec (1KB)
- Single-threaded read: 20K ops/sec (MemTable), 9.3K ops/sec (SSTable)
- Multi-threaded: 1.26x speedup at 4 threads
- Bloom filter: 240x speedup for non-existent keys
See BENCHMARK_RESULTS.md for detailed analysis.
- Column Families
- Transactions
- Snapshots
- Backup/Restore
- Iterator API improvements
Apache-2.0