Encrypted file system-based key-value store
Repo ActualLab/Kvasar, read from GitHub 9 h ago. ActualLab has not joined Take My Repo.
ActualLab/Kvasar is a public repo on GitHub by ActualLab. Encrypted file system-based key-value store. It declares the MIT license on GitHub. It is written mainly in C#, has 0 stars and last changed on 2026-11-21. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-25.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
Kvasar is a small, embedded, encrypted key-value store for .NET — pure managed, with zero native dependencies. It follows the fastest-path Bitcask model: an in-RAM hash index over an append-only, encrypted, paged log.
It replaced SQLite + SQLCipher as the on-device persistence engine for the client-side caches of Voxt (formerly ActualChat). Two reasons:
Kvasar is not a database. It has no queries, no transactions, no secondary indexes, and no
cross-key atomicity — just per-key Get/Set over binary keys and values. That narrowness is what
buys the speed.
Measured against a faithful replica of ActualChat's SQLiteBatchingKvasBackend (encrypted, WAL,
synchronous=normal, one connection per reader thread), with Kvasar using AES-256-GCM so both sides
are encrypted. Full methodology and raw tables in docs/BENCHMARKS.md.
Cold start is the most meaningful number: an app launch opens its client cache cold, then 8
threads speculatively render the UI — a burst of distinct-key reads (80% of the bytes are chat tiles,
20% misc values), 10% of which also write. SQLCipher runs in the stack it ships in (ActualChat's
BatchingKvas: a 256-entry LRU, batched reads, a 500 ms lazy writer); Kvasar runs with no layer at
all, app threads calling Get/Set directly, with its own 0.5 s FlushDelay for write debouncing.
| Cold start, median of three 5-run invocations | SQLCipher + BatchingKvas | Kvasar, no layer | Speedup |
|---|---|---|---|
| 12 MB cache, 1,000 reads | 54.0 ms | 7.7 ms | 7.0× |
| 25 MB cache, 2,000 reads | 123.9 ms | 11.3 ms | 11.0× |
These are durability-matched: the harness runs Kvasar at Flushed and checkpoints SQLite's WAL.
With Kvasar at Buffered, its totals are 7.2 / 10.0 ms; the matched flush costs 0.5 / 1.3 ms.
See docs/BENCHMARKS.md for both modes and the full run-to-run spread.
Batching layers exist to hide a slow backend; in front of Kvasar the same layer only costs time (9.2 / 14.0 ms), and its read cache never hits on a distinct-key burst.
A per-value-size sweep of the engines in isolation — 100k keys, 50-byte keys, 8 reader threads:
| Value size | Batched writes | Startup hydration | Point reads | Read p99 |
|---|---|---|---|---|
| 128 B (fits cache — the target scenario) | 3.9× | 1.0× | 75× | 1.4 µs vs 124 µs |
| 1 KB | 5.4× | 4.5× | 3.0× | 79 µs vs 147 µs |
| 4 KB (16 KB pages) | 7.7× | 7.4× | 1.8× | 133 µs vs 185 µs |
A warm read is one hash probe, one already-decrypted page, and a zero-copy slice — under 1 µs at the median, versus a B-tree descent through the SQLite VM. Where SQLite wins: opening a connection is trivially cheap, and its file is 17% smaller for 4 KB values even when Kvasar uses 16 KB pages. Startup hydration at 128 B is tied at about 141 ms; Kvasar's authenticated index load is eager while SQLite defers work.
The disk-bound 4 KB writes were the least repeatable result: Kvasar varied by 73–89% across runs, depending on page size. The page-size direction held, but treat the exact write multiple as one significant figure.
Three layers, each independently testable:
Paging/) — the .kdat data files: a plaintext 64-byte header followed by
AES-256-GCM encrypted pages, with a sharded byte-budgeted LRU cache of decrypted pages. Reads are
zero-copy slices into those cached, immutable pages.Internal/Log/) — records appended to the active .kdat slot. Values that fit a page
never span one, which is what keeps reads zero-copy. Compaction is automatic: at commit, when
two-thirds of the store is dead bytes, the whole live set is copied into the free slot and the
switch is a single superblock write. Nothing needs to call Compact().Index/) — an in-RAM open-addressing map from a keyed 64-bit key hash to a record
locator. Keys live on disk, not in the index, so index memory is independent of key length
(~16–24 B/entry). Persisted to .kidx as a checkpoint plus a delta tail, so opening is O(index)
rather than O(data).Concurrency: lock-free readers, single writer. The writer never blocks readers — it publishes a record by release-writing a 64-bit locator that readers acquire-read, and it always seals a page before publishing a locator into it, so readers only ever see immutable pages.
Async throughout. SQLite is synchronous for historical reasons; Kvasar is not. All disk I/O is
positional and async, with a CancellationToken on every path. It returns ValueTask, and Get is
deliberately not an async method — a cache hit completes synchronously with no state machine, no
allocation and no thread hop.
Kvasar buys atomicity, not durability: after any crash — process kill, OS crash, torn write,
power loss — it reopens at the state of some commit that completed, never at a partial or mixed one.
It does not promise that the most recent commit survives; for a regenerable cache a lost write
costs one upstream lookup, while a torn state costs correctness. That trade is what lets the whole
design work with no native code and at most one fsync per commit.
Writes are visible to readers as soon as Set returns, and are committed in batches: a commit
follows FlushDelay (0.5 s by default) after the first uncommitted write, or comes earlier once
CommitBytes accumulate. A process kill keeps everything up to the last commit, so with the default
delay it can lose up to the last half-second of writes; FlushDelay = TimeSpan.Zero commits every
write. Durability (Buffered by default, or Flushed) only decides how much survives an OS crash
or power loss.
The .kidx index is a hint, never the source of truth: on open, the store loads the checkpoint
and replays the log past it, so a stale, torn or tampered index costs a little startup time, never
data. Everything else degrades to wipe-and-recreate rather than an exception, because the store backs
a regenerable cache: a wrong key, a version mismatch, or unreadable state discards the files and
starts clean. See docs/DESIGN-Durability.md for the commit protocol
and its proof.
This is tested by killing a real child process mid-write at randomized points and asserting every
acknowledged record comes back — see tests/.../Store/ProcessCrashRecoveryTests.cs — plus randomized
crash fuzzing and fault injection over torn data, superblock and index writes.
AES-256-GCM per page under a caller-supplied 32-byte master key, with per-store subkeys derived via
HKDF-SHA256 and a fresh random salt per data file. Every page is authenticated, so tampering is
detected on read. Keys are hashed with keyed SipHash-2-4 so the .kidx leaks nothing about them.
What it does not defend against: an attacker who can put back an older copy of the store's files
(a rollback to a state the store really had authenticates fine — see the limitations in
docs/DESIGN.md), or anyone who has the master key.
await using var store = await KvasarStore.Open(new KvasarOptions {
BasePath = "/path/to/cache/CCC",
EncryptionKey = key32, // 32 bytes
Version = "1.0", // your data version; bump it and the store is wiped & recreated
});
await store.Set("some-key", value); // value == null => delete
var value = await store.Get("some-key"); // KvasarValue? — null = miss
Console.WriteLine(value?.AsString); // UTF-8 decode
await foreach (var (k, v) in store.Scan()) { … } // enumerate all (unordered)
await store.Flush();
Keys and values are binary — KvasarKey / KvasarValue, thin structs over
ReadOnlyMemory<byte> with implicit conversions from byte/char memory, byte[], char[] and
string (UTF-8), plus an AsString extension for the way back. KvasarOptions also exposes
PageSize, PageCacheBytes, compaction thresholds, and pluggable hasher/KDF — see
docs/SPEC.md §4.
Tune PageSize to your value size. It is the highest-leverage knob: values larger than a page
can't stay single-page, which costs both space and I/O. Moving 4 KB values from 4 KB to 16 KB pages
is +109% median writes, −34% file size, and −47% startup. The write magnitude is unstable; all
three 16 KB-page samples still beat all three 4 KB-page samples.
Released on NuGet and in production: Voxt's
client-side caches have run on it since its first NuGet release in July 2026. Changes are listed in
docs/CHANGELOG.md.
dotnet add package ActualLab.Kvasar
The library targets net11.0, net10.0 and net9.0, is AOT- and trimming-safe, and depends
on exactly one package (System.IO.Hashing).
Known limitations are tracked honestly in docs/DESIGN.md and
docs/TODO.md, including two worth knowing up front: two distinct keys sharing a
full 64-bit hash collapse to one entry (~2⁻⁶⁴ under the default keyed hasher; it never returns wrong
data, and a regenerable cache self-heals), and a compaction pass currently holds the write lock, so
it stalls writers for the length of the copy.
Build.cmd # or: dotnet build ActualLab.Kvasar.slnx -c Release
Run-Tests.cmd # full suite
Run-Benchmarks.cmd # vs SQLCipher; run on an idle machine
Build.cmd -p:UseMultitargeting=true # validate net11.0, net10.0 and net9.0
Publish.cmd # publish to NuGet via the Publish GitHub workflow
src/ActualLab.Kvasar/ Library (one dependency: System.IO.Hashing)
Crypto/ AES-GCM page cipher, SipHash-2-4, HKDF-SHA256
Paging/ Encrypted paged segments + LRU page cache
Internal/Log/ Append-only record log, segments, compaction
Index/ In-RAM hash index + .kidx persistence
tests/ActualLab.Kvasar.Tests/ Unit, property, concurrency, fuzz, crash-recovery
tools/ActualLab.Kvasar.CrashWorker/ Child process killed mid-write by the crash tests
benchmarks/ Kvasar vs sqlite-net-sqlcipher
docs/ SPEC.md (product spec), DESIGN.md (internals),
DESIGN-Durability.md (commit protocol), BENCHMARKS.md, CHANGELOG.md
MIT — see LICENSE.
ActualLab/Kvasar is a public repo on GitHub by ActualLab. Encrypted file system-based key-value store.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-21. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run Kvasar. What is known comes from GitHub. It declares the MIT license on GitHub. Its last change was on 2026-11-21. It has 0 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.