Status
v0.6. Page-oriented storage format (4 KB pages, B-tree index, free-list, WAL sidecar), automatic migration from v1/v2 log formats, optional memory-mapped reads, closure-based transactions with atomic batch writes, and a sharded in-memory primary index for fully parallel reads. The API is still pre-1.0 and may change before 1.0.
Track progress and roadmap: https://github.com/jamesgober/emdb-rs
Installation
[]
= "0.6"
Quick Start
use Emdb;
let db = open_in_memory;
db.insert?;
assert_eq!;
# Ok::
Persistence
use ;
let path = temp_dir.join;
let reopened = open?;
assert_eq!;
# let _cleanup = remove_file;
# Ok::
Manual compaction:
use Emdb;
let path = temp_dir.join;
let db = open?;
db.insert?;
db.compact?;
db.flush?;
# let _cleanup = remove_file;
# Ok::
Transactions
Commit path:
use Emdb;
let db = open_in_memory;
db.transaction?;
assert_eq!;
assert_eq!;
# Ok::
Rollback path:
use ;
let db = open_in_memory;
let failed = db.;
assert!;
assert_eq!;
# Ok::
Crash Safety
Transactions are written as BatchBegin ... BatchEnd records.
If a crash occurs before BatchEnd, the entire batch is discarded during
replay. If a crash occurs after BatchEnd, the entire batch is applied.
Features
ttl(default): per-record expiration and default TTL support.nested: dotted-prefix group operations andFocushandles.- persistence (core): append-only file log, replay-on-open, flush policy, and compaction.
- transactions (core): closure-based atomic batches with read-your-writes and crash-safe replay.
Concurrency
Emdb is Send + Sync and cheap to clone. Internally it uses a 32-shard
lock-striped primary index so reads on different keys never block each other,
plus a serialized backend mutex for the WAL and page file. In-memory
databases bypass the backend mutex entirely.
use Arc;
use thread;
use Emdb;
let db = new;
db.insert?;
let mut workers = Vecnew;
for i in 0_u32..4
for worker in workers
assert!;
# Ok::
TTL Example
#
#
# Ok::
Nested Example
#
#
# Ok::
Goals
- Embedded-first — runs in-process; no separate server, no network.
- High performance — zero-copy reads, allocation-free hot paths, cache-friendly layout.
- Safe — strict
clippyprofile, nounwrapin library code, allunsafedocumented. - Small footprint — minimal dependency graph, fast compile times.
- Portable — Linux, macOS, Windows (x86_64 and ARM64).
Benchmarking
emdb ships with Criterion benchmarks, including an optional comparative suite.
- Core benches: benches/kv.rs, benches/persistence.rs, benches/transactions.rs, benches/concurrency.rs
- Comparative bench: benches/comparative.rs
Quick start:
cargo bench --bench comparative
Compare with embedded DBs (sled + redb):
cargo bench --bench comparative --features bench-compare
Compare with RocksDB (optional):
cargo bench --bench comparative --features bench-rocksdb
Compare with Redis (optional):
$env:EMDB_REDIS_URL = "redis://127.0.0.1/"
cargo bench --bench comparative --features bench-redis
For full benchmark workflow, tuning, and reporting format, see docs/BENCH.md. The latest recorded baseline metrics are also tracked there.
Non-Goals
- Client-server operation (use a dedicated DBMS for that).
- A full SQL dialect at this stage.
- Distributed replication at this stage.
Related Projects
emdb is the Rust implementation. Implementations in other languages (Go, C, and others) are planned and will live under their own repositories.
License
Licensed under the Apache License, Version 2.0.
Copyright © 2026 James Gober.