A persistent key-value store built from scratch in Rust. Implements a Log-Structured Merge-Tree with WAL, SSTables, compaction, and a TCP frontend. Built as a systems engineering learning project.
- LSM-tree: in-memory
MemTable(HashMap) + disk-backed sorted SSTables. - Write-Ahead Log: all writes are appended to a log before acknowledgement; on restart, the WAL is replayed to restore state.
- Compaction: merges and prunes tombstoned entries in memory.
- Bloom filters (optional): reduce unnecessary disk lookups.
- Concurrency:
Arc<RwLock<T>>allows concurrent readers; writers take an exclusive lock. - TCP server: accepts multiple connections and dispatches them to the parser + engine.
| Operation | Throughput | Mechanism |
|---|---|---|
SET |
10 500 ops/s | WAL append + MemTable insert |
GET |
15 000 ops/s | MemTable lookup under RwLock read guard |
DEL |
O(1) in WAL | Tombstone insertion (no disk rewrite) |
Measures sequential round-trips over a local TCP connection. Higher concurrency possible with thread-pooling, but not included in these numbers.
- Network layer (
server.rs) – raw TCP, thread per connection. - Parser (
parser.rs) – zero-copy command parsing (SET, GET, DEL, COMPACT). - Engine (
engine.rs) – MemTable + WAL + SSTable compaction.
- WAL replay on boot recovers all committed writes.
- Tombstone-based deletion avoids immediate disk rewrites.
- Graceful shutdown on SIGINT: flushes pending WAL, closes sockets cleanly.
git clone https://github.com/baltasarblanco/chronos_lsm.git
cd chronos_lsmcargo runExpected Output:
🚀 CHRONOS SERVER LISTO Y ESCUCHANDO EN TCP 127.0.0.1:8080cargo run --bin clientchronos> SET user:101 {"name": "Venom", "role": "Symbiote"}
OK
chronos> GET user:101
{"name": "Venom", "role": "Symbiote"}
chronos> DEL user:101
OK_DELETED
chronos> COMPACT
OK_COMPACTED
MIT