BitDB

BitDB is a lightweight key/value store written in Go. It is a toy project that I worked on while learning Go. It follows
a Bitcask style architecture:
- Append-only segments – all writes are appended to the active segment file. Older segments become read-only.
- In-memory index – keys are mapped to the segment and byte offset of their latest value for fast reads.
- Background merging – old segments can be compacted into new ones to drop obsolete values and reclaim space.
Running
Run the server with go run and point it at a data directory:
go run ./cmd/server -path ./data
Then use the client to set and get keys:
go run ./cmd/client set foo bar
go run ./cmd/client get foo
Testing
To run tests:
just test
Test with race detector enabled:
just testrace
I run tests with race detector by default now.
Linting
For lint, we use golangci-lint tool. Run with:
just lint
Benchmarking/profiling
Results are on BENCHMARKS.md
I'm not doing these on my Mac so I don't wear down my ssd.
Run on hetzner or somewhere else(remember to change TMPDIR as written in justfile)
# Run all benchmarks
just bench
Profiling works by running benchmarks and opening a server.
After running the profiler, just go to $HOST:1730
# Profile Set
just profile Benchmark_Set