|
|
1 неделя назад | |
|---|---|---|
| bin | 7 месяцев назад | |
| .gitignore | 1 неделя назад | |
| README.md | 1 неделя назад | |
| benchmark.zig | 1 неделя назад | |
| benchmark_heavy.sh | 9 месяцев назад | |
| benchmark_heavy_redis.sh | 9 месяцев назад | |
| benchmark_no_pipeline.sh | 9 месяцев назад | |
| benchmark_no_pipeline_redis.sh | 9 месяцев назад | |
| command.zig | 1 неделя назад | |
| engine.zig | 1 неделя назад | |
| keydir.zig | 1 неделя назад | |
| main.zig | 1 неделя назад | |
| makefile | 1 неделя назад | |
| migration.zig | 1 неделя назад | |
| ordered_index.zig | 1 неделя назад | |
| pkbfi.zig | 1 неделя назад | |
| pkvdb.zig | 1 неделя назад | |
| redis.zig | 1 неделя назад | |
| requirements.md | 10 месяцев назад | |
| socket.zig | 1 неделя назад |
An in-memory key-value store written in Zig with Redis protocol compatibility and persistent storage.
PizzaKV is a concurrent key-value database that implements a subset of the Redis RESP (REdis Serialization Protocol), allowing it to work with Redis clients for supported commands. It also supports a simpler custom protocol (Pizzaria Protocol) using \r delimiters. Built from scratch in Zig.
\r-delimited custom protocolSET key value - Store a key-value pairGET key - Retrieve a value by keyDEL key - Delete a key\r-delimited)write key|value - Write a key-value pair (key and value separated by |)read key - Read a value by keydelete key - Delete a keykeys - Get all keys (using radix tree)reads prefix - Get all values for keys matching a prefixstatus - Server status check# Build optimized binary
make build
# Clean build artifacts
make clean
# Start server in Redis mode (RESP protocol, port 8085)
./pizzakv -redis
# Start server in Pizzaria mode (\r-delimited protocol, port 8085)
./pizzakv
# Custom port
./pizzakv -port=9000
# Unix socket mode (creates .pizzakv.sock in current directory)
./pizzakv -unix
./pizzakv -unix -redis
# The server will create a .db file for persistence.
# In unix mode, a .pizzakv.sock file is also created and removed on shutdown.
PizzaKV includes comprehensive benchmark suites comparing against Redis:
# Heavy workload benchmarks (with pipelining)
./benchmark_heavy.sh # PizzaKV
./benchmark_heavy_redis.sh # Redis comparison
# No-pipeline benchmarks (raw latency)
./benchmark_no_pipeline.sh # PizzaKV
./benchmark_no_pipeline_redis.sh # Redis comparison
Both systems tested with AOF persistence enabled.
| Test | PizzaKV | Redis (AOF) | Winner |
|---|---|---|---|
| Write Load (1M × 256B) | 363K ops/sec 7.88ms p50 |
571K ops/sec 4.87ms p50 |
Redis 1.57× |
| Read Load (1M reads) | 1.29M ops/sec 1.06ms p50 |
1.33M ops/sec 2.18ms p50 |
PizzaKV (latency) |
| Large Values (100k × 10KB) | 133K ops/sec 3.98ms p50 |
80K ops/sec 3.34ms p50 |
PizzaKV 1.67× |
| Extreme Concurrency (200 clients) | 333K writes 965K reads |
500K writes 998K reads |
Redis |
Single-request latency comparison - the true test of performance.
| Test | PizzaKV p50 | Redis p50 | Improvement |
|---|---|---|---|
| Small Writes (256B) | 0.159ms | 0.295ms | 46% faster ⚡ |
| Small Reads | 0.175ms | 0.207ms | 15% faster ⚡ |
| Medium Writes (1KB) | 0.175ms | 0.255ms | 31% faster ⚡ |
| Medium Reads (1KB) | 0.159ms | 0.175ms | 9% faster ⚡ |
| Large Writes (10KB) | 0.111ms | 0.199ms | 44% faster ⚡⚡⚡ |
| Large Reads (10KB) | 0.095ms | 0.103ms | 8% faster ⚡ |
| High Concurrency (100 clients) | 0.303ms | 0.327ms | 7% faster ⚡ |
Simple append-only format:
OPCODE|key|value\r
W|key|value\r - Write operationD|key|\r - Delete operationpizzakv/
├── main.zig # Server, connection handling
├── storage.zig # Sharded hash table
├── index.zig # Radix tree for prefix search
├── persistence.zig # AOF persistence layer
├── hashing.zig # Hash function
├── redis.zig # RESP protocol parser
├── command.zig # Command execution
├── socket.zig # TCP and Unix socket operations
└── benchmark_*.sh # Benchmark scripts
-O ReleaseFast optimization