Skip to content

baltasarblanco/chronos_lsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦀 Chronos — LSM-Tree Key-Value Store

Rust Arch License Reads Writes

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.


⚙️ Internals

  • 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.

📊 Benchmarks (single-thread, localhost, 10,000 ops)

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.


🏗️ Architecture

  1. Network layer (server.rs) – raw TCP, thread per connection.
  2. Parser (parser.rs) – zero-copy command parsing (SET, GET, DEL, COMPACT).
  3. Engine (engine.rs) – MemTable + WAL + SSTable compaction.

🛡️ Durability & Recovery

  • 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.

🚀 Quick Start

1. Clone

git clone https://github.com/baltasarblanco/chronos_lsm.git
cd chronos_lsm

2. Run the Server

cargo run

Expected Output:

🚀 CHRONOS SERVER LISTO Y ESCUCHANDO EN TCP 127.0.0.1:8080

3. Interactive CLI (built-in client)

cargo run --bin client

4. Example session

chronos> 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

📄 License

MIT

About

LSM‑tree KV store in Rust with WAL, bloom filters, compaction. Bench: ~15k reads/s · ~10.5k writes/s (single‑thread, localhost).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages