본문으로 건너뛰기
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL

Show HN: RamusDB is an inmem KV database with branching

Redis compatible. Fork your data like a git branch in nanoseconds, change each copy independently and connect with redis-cli. You pay only for the memory as branches diverge. Comments URL: https://news.ycombinator.com/item?id=50673880 Points: 2 # Comments: 0

번역 서비스가 일시 중지되어 원문을 표시합니다.

RamusDB is an experimental in-memory key-value database, written in Zig, built around cheap, independently writable branches. Fork your data like a git branch in nanoseconds, change each copy independently, and connect with redis-cli. You pay only for the memory as branches diverge. Questions, bugs: join the Discord. Branches BRANCH dev creates a branch without copying any data. Both branches point at the same root; a write copies only the path it touches. flowchart LR subgraph s1["1. after BRANCH dev: one shared root"] direction TB m1(["main"]) --> r1(("root")) d1(["dev"]) --> r1 r1 --> a1["subtree A"] r1 --> b1["subtree B"] end subgraph s2["2. after SET on dev: only the path is copied"] direction TB m2(["main"]) --> r2(("root")) d2(["dev"]) --> r3(("root'")) r2 --> a2["subtree A"] r2 --> b2["subtree B"] r3 --> a2 r3 --> b3["subtree B' (copy)"] end s1 --> s2 Cheap branch creation: a new branch retains the source branch's root; nothing is copied. Shared data structures: each branch is a complete version of a persistent, reference-counted HAMT; unchanged subtrees are shared by every branch that contains them. Independent mutations via copy-on-write: a write never changes another branch. A branch that exclusively owns its path mutates it in place; a shared path is copied first. zig build server -Doptimize=ReleaseFast # starts on 127.0.0.1:6380 redis-cli -p 6380 # in another terminal 127.0.0.1:6380> SET foo bar OK 127.0.0.1:6380> BRANCH dev OK 127.0.0.1:6380> USE dev OK 127.0.0.1:6380> SET foo baz OK 127.0.0.1:6380> GET foo "baz" 127.0.0.1:6380> USE main OK 127.0.0.1:6380> GET foo "bar" The server implements GET, SET, DEL, BRANCH, USE, BRANCHES, DELBRANCH, PING, ECHO, HELLO and QUIT. It is not a Redis replacement: no persistence, no authentication, no RESP3, no other Redis commands (details). Benchmark snapshot: RamusDB vs Redis Plain key-value operations on a single branch (main), same C load generator for both servers, loopback TCP, Redis 8.12.0 with persistence off and one I/O thread, on one Apple A18 Pro laptop. Throughput and latency are separate charts: latency is the per-command round trip seen by the client. Preliminary. One small machine, short measurement windows, client and servers sharing cores. The GET runs are 3 repetitions of 3 s on 100k keys, taken at an earlier commit (3ca9030); the SET runs are 5 repetitions of 0.8-1.5 s. In the GET runs RamusDB used about 2-2.5 cores of server CPU against 0.7-0.9 for Redis. DEL is not shown: RamusDB is ahead with 1 client and behind (0.73x) with 8. Branch operations are not benchmarked here. Methodology, other workloads and raw data: bench/README.md, mini-demo summary. Regenerate the chart from those files with python3 bench/readme_chart.py. Cost of a write on a branch A write on a branch that still shares its tree with another branch used to copy the whole path from the root. Now it mutates what the branch owns exclusively and copies only the shared part. Results and memory are the same, the writes are cheaper: with 1M keys and a fork that keeps writing existing keys while main is alive, 289 → 164 ns and 336 → 104 B per write over the first million writes (1.76x; before the change). New keys: 1.5x. Zipf-distributed keys: 1.5x. The chart shows the overhead that remains compared with a branch that was never forked: about twice the time right after a fork, gone after roughly 30k writes. Preliminary. One laptop, in-process (no network), uniform keys unless stated. A write on a branch that owns its path was not changed (92 B, 170-180 ns here); the first writes after a fork still cost up to twice that, and DEL is not changed. A cost of up to about 10% on that exclusive update cannot be excluded (L87). Methodology and raw data: COW_REPORT.md (section 10). Regenerate the chart from the result files with python3 bench/readme_cow_chart.py. docs/SERVER.md: commands, RESP support, production build, architecture of the server. docs/MEMORY.md: how the index and branches own and free memory. docs/TESTING.md: test tiers, ownership verification, randomized branch-isolation fuzz, mutation survey. bench/README.md: benchmark suite, methodology and results. LIMITATIONS.md: known limitations, bugs and assumptions. Apache License 2.0, see LICENSE. The vendored C library in vendor/hamt keeps its own MIT license.

자료 출처

원문 읽기 ↗

관련 주제

← 전체 소식 이어 읽기