LokiKV is a specialized Key-Value storage engine built with Modern C++20, focusing on Data Durability (WAL), Thread-Safety (Shared Mutex), and Binary Persistence (SSTables).
-
Durability Layer (WAL): Every write is serialized to an append-only binary Log-Structured file before hitting memory, ensuring 100% recovery from system crashes.
-
Concurrency Layer (MemTable): Utilizes
std::shared_mutexto implement a high-performance Reader-Writer pattern, allowing concurrent lookups while maintaining exclusive write integrity. -
Persistence Layer (SSTable): Implements immutable on-disk storage with a Binary Index Footer, enabling
$O(\log N)$ point-lookups without loading the entire dataset into memory. -
Compaction Engine: Background multi-way merge-sort logic leveraging C++20
std::jthreadandstd::stop_tokenfor graceful, leak-free termination.
This project was built following a strict "Red-Green-Refactor" cycle, verified by Catch2 and AddressSanitizer (ASan).
| Phase | Component | Verification |
|---|---|---|
| Phase 1 | WAL | Asserted that cleared MemTables can be reconstructed from binary logs |
| Phase 2 | MemTable | Verified thread-safety by simulating 1,000+ concurrent writes across multiple worker threads |
| Phase 3 | SSTable | Validated on-disk binary search logic and footer-offset calculation |
| Phase 4 | Integration | Full engine orchestration tests ensuring cohesive interaction between all layers |
| Specification | Technology |
|---|---|
| Language | C++20 |
| Build System | CMake + Ninja |
| Dependency Management | vcpkg + Vendored Headers (GSL, Catch2) |
| Memory Safety | Strict adherence to Microsoft GSL (Guidelines Support Library) using gsl::span |
| CI/CD | GitHub Actions automation with ASan validation for memory leak prevention |
# Configure with AddressSanitizer for safety verification
cmake -S . -B build -DCMAKE_CXX_FLAGS="-fsanitize=address"
cmake --build build
# Run the comprehensive test suite
./build/Integration_Tests