SNKV – SQLite's B-tree as a key-value store (C/C++ and Python bindings)
SQLite B-tree without SQL: 57–68% faster KV ops, single-header drop-in.
SNKV — a lightweight key-value store focused on simplicity, security and performance file based database , written using b-tree directly. Now supports vector HNSW , Join the discussion: https://discord.gg/EUb4Y5qE
Skip SQL entirely; direct B-tree KV API cuts RocksDB memory from 121MB to 11MB.
Systems engineers, embedded database users, resource-constrained environments
RocksDB · LevelDB · LSM-tree engines
B-tree operations: https://github.com/hash-anu/snkv/blob/master/internal/BTREE_... Pager operations: https://github.com/hash-anu/snkv/blob/master/internal/PAGER_... OS layer operations: https://github.com/hash-anu/snkv/blob/master/internal/OS_LAY...
Once I understood the core pieces, I built a simple key-value store directly on top of SQLite's B-tree layer — reusing its storage management, paging, and file I/O without touching the SQL engine at all.
I then added column family support, WAL and journal modes, and transactions. For easier integration, I generated a single amalgamated header (similar to SQLite's approach): https://github.com/hash-anu/snkv
Benchmarks (1M records, sync-on-commit enabled for both):
RocksDB SNKV
Sequential writes: 237K/s 181K/s Random reads: 95K/s 154K/s Sequential scan: 1.78M/s 5.95M/s Mixed workload: 51K/s 97K/s Peak memory (RSS): 121 MB 10.8 MB (~11x less)RocksDB's LSM-tree design gives it a clear write advantage, and with tuning (bloom filters, larger caches) its read numbers would improve too. The memory gap is structural though — RocksDB carries significantly more overhead even when constrained to a small footprint configuration.
The full KV layer documentation is here: https://github.com/hash-anu/snkv/blob/master/internal/KVSTOR...
Curious if others have hit the same memory wall with RocksDB on small workloads, or taken a different approach to this tradeoff.
SQLite B-tree without SQL: 57–68% faster KV ops, single-header drop-in.
SQLite's proven storage minus SQL parsing—3–5× throughput for KV-only workloads.
Single-file SQLite memory for LLMs simplifies complex vector DBs for local workflows.
Offline semantic memory for agents: SQLite + ONNX embeddings, no API needed.
Local-only agent memory when mem0 and supermemory require servers.
Semantic memory extraction in browser SQLite, but local AI assistants are crowded.