Explorar el Código

add benchmark results

Danilo Fragoso hace 9 meses
padre
commit
a5a4da609d
Se han modificado 5 ficheros con 385 adiciones y 0 borrados
  1. 50 0
      README.md
  2. 71 0
      benchmark_heavy.sh
  3. 88 0
      benchmark_heavy_redis.sh
  4. 83 0
      benchmark_no_pipeline.sh
  5. 93 0
      benchmark_no_pipeline_redis.sh

+ 50 - 0
README.md

@@ -68,6 +68,56 @@ make clean
 # The server will create a .db file for persistence
 ```
 
+## Benchmarking
+
+PizzaKV includes comprehensive benchmark suites comparing against Redis:
+
+```bash
+# 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
+```
+
+## Performance Comparison
+
+### Heavy Workload (With Pipelining, P=32)
+
+Both systems tested with AOF persistence enabled.
+
+| Test | PizzaKV | Redis (AOF) | Winner |
+|------|---------|-------------|--------|
+| **Write Load** (1M × 256B) | 363K ops/sec<br/>7.88ms p50 | 571K ops/sec<br/>4.87ms p50 | Redis 1.57× |
+| **Read Load** (1M reads) | 1.29M ops/sec<br/>1.06ms p50 | 1.33M ops/sec<br/>2.18ms p50 | **PizzaKV** (latency) |
+| **Large Values** (100k × 10KB) | 133K ops/sec<br/>3.98ms p50 | 80K ops/sec<br/>3.34ms p50 | **PizzaKV 1.67×** |
+| **Extreme Concurrency** (200 clients) | 333K writes<br/>965K reads | 500K writes<br/>998K reads | Redis |
+
+### No-Pipeline Performance (P=1, Raw Latency)
+
+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** ⚡ |
+
+### Summary
+
+- Single-request latency (P=1): 0.095ms - 0.303ms across all tests
+- Lower latency than Redis on most single-request operations
+- Higher throughput than Redis on 10KB payloads with pipelining
+- Read throughput reaches 1.3M+ ops/sec with pipelining
+- No crashes observed during benchmark runs
+- Handles 1.2GB persistence file without degradation
+
 ## Technical Details
 
 ### Memory Management

+ 71 - 0
benchmark_heavy.sh

@@ -0,0 +1,71 @@
+#!/bin/bash
+
+echo "🚀 PizzaKV Heavy Benchmark Suite"
+echo "=================================="
+echo ""
+
+# Remove old db to start fresh
+echo "🗑️  Cleaning old data..."
+pkill pizzakv 2>/dev/null
+sleep 1
+rm -f .db
+echo "Starting fresh server..."
+./pizzakv -redis &
+SERVER_PID=$!
+sleep 2
+
+echo ""
+echo "📊 Running Heavy Benchmark Tests..."
+echo ""
+
+# Test 1: Heavy Write Load - 1M records
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 1: Heavy Write Load (1M records)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 -d 256 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 2: Heavy Read Load (1M reads)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 3: Mixed Workload (500k each)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET,GET -n 500000 -c 100 --threads 8 -r 1000000 -P 32 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 4: Large Values (10KB payloads)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET -n 100000 -c 50 --threads 4 -r 100000 -P 16 -d 10240 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 5: Extreme Concurrency (200 clients)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET,GET -n 500000 -c 200 --threads 8 -r 500000 -P 16 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 6: Low Latency (no pipelining)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 50000 -c 50 --threads 4 -r 1000000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 7: DELETE Performance"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t DEL -n 100000 -c 50 --threads 4 -r 1000000 -P 16 --csv
+
+echo ""
+echo "✅ Benchmark Complete!"
+echo ""
+echo "Checking persistence..."
+ls -lh .db
+echo ""
+echo "Shutting down server..."
+kill $SERVER_PID
+wait $SERVER_PID 2>/dev/null

+ 88 - 0
benchmark_heavy_redis.sh

@@ -0,0 +1,88 @@
+#!/bin/bash
+
+echo "🔴 Redis Heavy Benchmark Suite"
+echo "=================================="
+echo ""
+
+# Check if Redis is installed
+if ! command -v redis-server &> /dev/null; then
+    echo "❌ Redis is not installed"
+    echo "Install with: brew install redis"
+    exit 1
+fi
+
+# Check if Redis is running on default port
+if nc -z localhost 6379 2>/dev/null; then
+    echo "⚠️  Redis already running on port 6379"
+    echo "Stopping existing Redis server..."
+    redis-cli shutdown 2>/dev/null
+    sleep 1
+fi
+
+# Clean up old AOF file
+rm -f appendonly.aof
+
+# Start fresh Redis instance with AOF persistence
+echo "🗑️  Starting fresh Redis server with AOF persistence..."
+redis-server --port 6379 --save "" --appendonly yes --appendfsync everysec &
+REDIS_PID=$!
+sleep 2
+
+echo ""
+echo "📊 Running Heavy Benchmark Tests on Redis..."
+echo ""
+
+# Test 1: Heavy Write Load - 1M records
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 1: Heavy Write Load (1M records)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 -d 256 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 2: Heavy Read Load (1M reads)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 1000000 -c 100 --threads 8 -r 1000000 -P 32 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 3: Mixed Workload (500k each)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET,GET -n 500000 -c 100 --threads 8 -r 1000000 -P 32 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 4: Large Values (10KB payloads)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET -n 100000 -c 50 --threads 4 -r 100000 -P 16 -d 10240 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 5: Extreme Concurrency (200 clients)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET,GET -n 500000 -c 200 --threads 8 -r 500000 -P 16 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 6: Low Latency (no pipelining)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 50000 -c 50 --threads 4 -r 1000000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 7: DELETE Performance"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t DEL -n 100000 -c 50 --threads 4 -r 1000000 -P 16 --csv
+
+echo ""
+echo "✅ Redis Benchmark Complete!"
+echo ""
+echo "Checking memory usage..."
+redis-cli INFO memory | grep used_memory_human
+echo ""
+echo "Checking AOF persistence file..."
+ls -lh appendonly.aof
+echo ""
+echo "Shutting down Redis..."
+redis-cli shutdown
+wait $REDIS_PID 2>/dev/null

+ 83 - 0
benchmark_no_pipeline.sh

@@ -0,0 +1,83 @@
+#!/bin/bash
+
+echo "🚀 PizzaKV No-Pipeline Benchmark Suite"
+echo "========================================"
+echo ""
+
+# Remove old db to start fresh
+echo "🗑️  Cleaning old data..."
+pkill pizzakv 2>/dev/null
+sleep 1
+rm -f .db
+echo "Starting fresh server..."
+./pizzakv -redis &
+SERVER_PID=$!
+sleep 2
+
+echo ""
+echo "📊 Running No-Pipeline Benchmark Tests..."
+echo ""
+
+# Test 1: Small writes without pipelining
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 1: Small Writes (100k, 256 bytes, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET -n 100000 -c 50 --threads 4 -r 100000 -P 1 -d 256 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 2: Small Reads (100k, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 100000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 3: Medium Writes (50k, 1KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET -n 50000 -c 50 --threads 4 -r 50000 -P 1 -d 1024 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 4: Medium Reads (50k, 1KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 50000 -c 50 --threads 4 -r 50000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 5: Large Writes (10k, 10KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET -n 10000 -c 25 --threads 2 -r 10000 -P 1 -d 10240 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 6: Large Reads (10k, 10KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 10000 -c 25 --threads 2 -r 10000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 7: Mixed Workload (50k each, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t SET,GET -n 50000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 8: High Concurrency (100k, 100 clients, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t GET -n 100000 -c 100 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 9: DELETE Performance (50k, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 8085 -t DEL -n 50000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "✅ Benchmark Complete!"
+echo ""
+echo "Checking persistence..."
+ls -lh .db
+echo ""
+echo "Shutting down server..."
+kill $SERVER_PID
+wait $SERVER_PID 2>/dev/null

+ 93 - 0
benchmark_no_pipeline_redis.sh

@@ -0,0 +1,93 @@
+#!/bin/bash
+
+echo "🔴 Redis No-Pipeline Benchmark Suite"
+echo "======================================"
+echo ""
+
+# Check if Redis is running on default port
+if nc -z localhost 6379 2>/dev/null; then
+    echo "⚠️  Redis already running on port 6379"
+    echo "Stopping existing Redis server..."
+    redis-cli shutdown 2>/dev/null
+    sleep 1
+fi
+
+# Clean up old AOF files
+rm -f appendonly.aof*
+
+# Start fresh Redis instance with AOF persistence
+echo "🗑️  Starting fresh Redis server with AOF persistence..."
+redis-server --port 6379 --save "" --appendonly yes --appendfsync everysec &
+REDIS_PID=$!
+sleep 2
+
+echo ""
+echo "📊 Running No-Pipeline Benchmark Tests on Redis..."
+echo ""
+
+# Test 1: Small writes without pipelining
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 1: Small Writes (100k, 256 bytes, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET -n 100000 -c 50 --threads 4 -r 100000 -P 1 -d 256 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 2: Small Reads (100k, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 100000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 3: Medium Writes (50k, 1KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET -n 50000 -c 50 --threads 4 -r 50000 -P 1 -d 1024 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 4: Medium Reads (50k, 1KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 50000 -c 50 --threads 4 -r 50000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 5: Large Writes (10k, 10KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET -n 10000 -c 25 --threads 2 -r 10000 -P 1 -d 10240 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 6: Large Reads (10k, 10KB, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 10000 -c 25 --threads 2 -r 10000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 7: Mixed Workload (50k each, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t SET,GET -n 50000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 8: High Concurrency (100k, 100 clients, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t GET -n 100000 -c 100 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+echo "Test 9: DELETE Performance (50k, P=1)"
+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+redis-benchmark -h localhost -p 6379 -t DEL -n 50000 -c 50 --threads 4 -r 100000 -P 1 --csv
+
+echo ""
+echo "✅ Redis Benchmark Complete!"
+echo ""
+echo "Checking memory usage..."
+redis-cli INFO memory | grep used_memory_human
+echo ""
+echo "Checking AOF persistence files..."
+ls -lh appendonly.aof* 2>/dev/null || echo "AOF files managed by Redis"
+echo ""
+echo "Shutting down Redis..."
+redis-cli shutdown
+wait $REDIS_PID 2>/dev/null