A high-performance, embeddable, log-structured key-value store inspired by Bitcask. This project is written in Go and emphasizes simplicity, speed, and crash resilience.
- ✅ Append-only log for all writes
- ✅ In-memory hash index (key → offset)
- ✅ Idempotent segment loading
- ✅ Support for multiple data segments
- ✅ Efficient point lookups
- ✅ Tombstone creation on key deletion
- ✅ Crash resilient
Collected against running benchmarks defined in tests/bench_test.go file on 8-core CPU and 16GB unified memory
| Metric | Operations | Throughput | Notes |
|---|---|---|---|
| Sequential Writes | 422780 | 364K writes/sec | Baseline test |
| Random Writes | 402643 | 321K writes/sec | |
| Sequential Reads | 1259307 | 1177K ops/sec | Baseline test |
| Random Reads | 1210428 | 1000K ops/sec | |
| Mixed Workload (70% R + 30% W) | 516225 | 336K ops/sec | Real world scenario |
| Compaction | 15 | 77ms/op | Compaction benchmark |
- Data is stored in segment files on disk in a serialized binary format.
- An in-memory hash index maps keys to offsets in these segment files.
- Deletion is handled via tombstone entries, written just like regular records.
- If the store crashes or is restarted, segments are replayed to reconstruct the in-memory index on startup.
- Go 1.22.2 or higher
- Git
git clone https://github.com/201901407/bitcask-go.git
cd bitcask
go run main.goThis store supports the following operations:
| Command | Description | Example |
|---|---|---|
set <key> <value> |
Sets a key-value pair in the store | set name Alice |
get <key> |
Retrieves the value for a given key | get name |
delete <key> |
Deletes the key-value pair from the store | delete name |
stop |
Gracefully shuts down the store | stop |
bitcask/
├── go.mod # Go module definition
├── main.go # Entry point for the application
├── README.md # Project documentation
└── store/
└── bitcask_store.go # Core implementation of the Bitcask KV store