Skip to main content
Swytch Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Benchmarks

Swytch includes built-in benchmark suites for both the cache engine and Redis command handling. You can also use the standard redis-benchmark tool.

Running Benchmarks

Cache Engine Benchmarks

go test -bench=. -benchmem ./cache/

These benchmarks exercise the CloxCache (L0 in-memory layer) directly, without Redis protocol overhead:

BenchmarkDescription
BenchmarkCloxCacheGetParallel GET on 10k keys
BenchmarkCloxCachePutParallel PUT operations
BenchmarkCloxCacheMixed80% read / 20% write workload, reports hit rate and evictions
BenchmarkCloxCacheZipfZipf distribution (theta=0.99) simulating realistic hotspot access
BenchmarkCloxCacheContentionHigh contention on 100 hot keys
BenchmarkCloxCacheSizesScaling across Small, Medium, Large, and XLarge cache sizes
BenchmarkCloxCachePointersPointer-type values

Each benchmark also has a sync.Map variant for comparison.

Redis Command Benchmarks

go test -bench=. -benchmem ./redis/

These benchmarks exercise the full Redis command pipeline including parsing, execution, and response writing:

BenchmarkDescription
BenchmarkHandler_SetSET command throughput
BenchmarkHandler_GetGET command throughput (pre-populated 10k keys)
BenchmarkHandler_IncrINCR atomic counter
BenchmarkHandler_IncrByINCRBY atomic counter
BenchmarkHandler_LPushLPUSH list operations
BenchmarkHandler_RPushRPUSH list operations
BenchmarkHandler_LPopLPOP list operations
BenchmarkHandler_RPopRPOP list operations
BenchmarkHandler_LRangeLRANGE range queries
BenchmarkHandler_LIndexLINDEX positional lookup
BenchmarkHandler_HSetHSET hash field writes
BenchmarkHandler_HGetHGET hash field reads
BenchmarkHandler_HGetAllHGETALL full hash retrieval
BenchmarkHandler_HIncrByHINCRBY atomic hash field increment
BenchmarkHandler_Mixed80/20 read/write mixed workload
BenchmarkHandler_ParallelMulti-goroutine GET/SET
BenchmarkHandler_LargeValues10KB value SET/GET
BenchmarkHandler_LPushScalabilityLPUSH scaling from 1K to 10M list elements

Effects Engine Benchmarks

go test -bench=. -benchmem ./effects/

Benchmarks for the causal effect resolution layer.

Using redis-benchmark

Swytch is compatible with the standard redis-benchmark tool:

# Basic throughput test
redis-benchmark -p 6379 -n 100000 -c 50

# GET/SET only
redis-benchmark -p 6379 -t set,get -n 1000000 -c 100

# Pipeline mode (higher throughput)
redis-benchmark -p 6379 -t set,get -n 1000000 -P 16

# With specific key size and value size
redis-benchmark -p 6379 -t set,get -d 256 -r 1000000

Typical Flags

FlagDescription
-nTotal number of requests
-cNumber of parallel connections
-PPipeline N requests per connection
-tComma-separated list of commands to benchmark
-dData size in bytes for SET values
-rUse random keys from a range of this size
-qQuiet mode (show only requests/sec)

Workload Patterns

Zipf Distribution

The cache benchmarks include a Zipf workload generator (theta=0.99) that simulates realistic access patterns where a small number of keys receive the majority of traffic. This is representative of most production workloads.

Hot Key Contention

The contention benchmark concentrates all access on 100 keys across many goroutines. This stress-tests the sharded locking and adaptive serialization paths.

Trace Datasets

For reproducible cache evaluations, trace files are available from the CacheMon cache_dataset project. These real-world traces can be replayed against Swytch to compare eviction behavior across different workloads.