Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
A fast, embedded key-value store in Rust
TurboKV is a high-performance, embedded key-value database written in Rust. It provides a clean API with configurable durability guarantees.
Features
- Simple API: Familiar
get,insert,remove,rangeoperations - Configurable Durability: Choose between fast, durable, or paranoid modes
- LSM-Tree Architecture: Optimized for write-heavy workloads
- Async/Await: Built on Tokio for modern async Rust
- Batch Operations: Atomic write batches for transactional writes
- Range Scans: Efficient prefix and range queries
- Block Cache: Configurable caching for read performance
- Bloom Filters: Fast negative lookups
- Compression: LZ4, Snappy, and Zstd support
Quick Start
Add TurboKV to your Cargo.toml:
[]
= "0.2"
= { = "1", = ["full"] }
Basic Usage
use ;
async
Batch Writes
use ;
let db = open.await?;
// Atomic batch write
let mut batch = new;
batch.put;
batch.put;
batch.delete;
db.write_batch.await?;
Configuration Options
TurboKV provides three durability modes to balance speed and safety:
| Mode | WAL | Fsync | On Crash |
|---|---|---|---|
fast() |
No | No | Flushed data survives; unflushed data lost |
durable() |
Yes | Periodic | All data survives process crash |
paranoid() |
Yes | Every write | All data survives power loss |
Recommended for most users: fast() or durable() mode.
- Use
fast()when data can be regenerated or occasional loss is acceptable - Use
durable()for production data that must survive process crashes
The paranoid() mode is for specialized use cases where you need power-loss durability. This mode is significantly slower due to fsync overhead (~257 ops/sec vs ~1.1M ops/sec).
use ;
// Fast mode - maximum speed, no durability guarantees
// Best for: caches, temporary data, benchmarks
let db = open_with_options.await?;
// Durable mode (RECOMMENDED) - WAL protects against process crashes
// Best for: most production workloads
let db = open_with_options.await?;
// Paranoid mode - fsync on every write
// Best for: financial transactions, critical records
let db = open_with_options.await?;
Custom Configuration
use ;
let options = DbOptions ;
let db = open_with_options.await?;
Compression options:
Compression::None- No compression (fastest writes, largest files)Compression::Lz4- Very fast compression (default, best for most workloads)Compression::Snappy- Fast compression (good balance)Compression::Zstd- High compression ratio (smaller files, slower)
Components
- WAL (Write-Ahead Log): Ensures durability by logging writes before applying
- MemTable: In-memory skip list for fast writes
- SSTable: Sorted, immutable files on disk with bloom filters
- Block Cache: LRU cache for frequently accessed data blocks
- Compaction: Background process to merge SSTables and reclaim space
Performance
TurboKV is optimized for high write throughput and outperforms both RocksDB and fjall.
Production-scale benchmark: 10M keys, 400-byte values (4.2GB total)
| Database | Mode | Throughput |
|---|---|---|
| TurboKV | fast (no WAL) | 1,132K ops/sec |
| TurboKV | durable (WAL) | 1,094K ops/sec |
| RocksDB | default (WAL) | 560K ops/sec |
| fjall | default | 501K ops/sec |
| TurboKV | paranoid (fsync/write) | ~257 ops/sec |
| Other Operations | Performance |
|---|---|
| Random reads | ~760K ops/sec |
| Range scans | ~1.2M entries/sec |
| Concurrent writes (8 writers, paranoid) | ~1000 ops/sec |
Benchmarks on Apple Silicon Mac, SSD storage, RocksDB-comparable parameters (20-byte keys, 400-byte values)
Understanding the Numbers
How does TurboKV compare?
- TurboKV is 2x faster than RocksDB with equivalent durability (WAL enabled)
- TurboKV is 2.25x faster than fjall
- TurboKV provides a simpler async API with zero-allocation write paths
Why is paranoid mode so slow? Every write calls fsync() which takes 3-5ms on SSDs. This is a hardware limitation that affects all databases equally. RocksDB and fjall hit the same bottleneck (~200-300 ops/sec) when configured for power-loss durability.
Why is durable mode much faster? It writes to the WAL but relies on the OS to fsync() periodically (every few seconds). This "periodic sync" approach means data survives process crashes but not sudden power loss. This is what RocksDB does by default (sync_wal: false).
Comparison
| Feature | TurboKV | RocksDB | fjall |
|---|---|---|---|
| Language | Rust | C++ | Rust |
| Write throughput | 1.1M ops/sec | 560K ops/sec | 501K ops/sec |
| Async support | Yes | No | No |
| BTreeMap-like API | Yes | No | Yes |
| Learning curve | Low | High | Low |
API Reference
Db
| Method | Description |
|---|---|
open(path) |
Open database with default options |
open_with_options(path, options) |
Open with custom options |
insert(key, value) |
Insert or update a key-value pair |
get(key) |
Get value by key |
remove(key) |
Delete a key |
contains_key(key) |
Check if key exists |
range(start, end) |
Scan keys in range [start, end) |
scan_prefix(prefix) |
Scan all keys with prefix |
write_batch(batch) |
Atomic batch write |
flush() |
Flush memtable to disk |
compact() |
Trigger manual compaction |
stats() |
Get database statistics |
DbOptions
| Field | Default | Description |
|---|---|---|
wal_enabled |
true | Enable write-ahead log |
sync_writes |
false | Sync writes to disk (true = paranoid mode) |
memtable_size |
64MB | MemTable size before flush |
block_cache_size |
64MB | Block cache size (0 to disable) |
compression |
Lz4 | Compression algorithm |
WriteBatch
| Method | Description |
|---|---|
new() |
Create empty batch |
put(key, value) |
Add insert operation |
delete(key) |
Add delete operation |
len() |
Number of operations |
clear() |
Clear all operations |
Development
# Build
# Run tests
# Run benchmarks
# Format code
# Lint