Capstone: benchmark against real Redis

Go closes most of the gap to C Redis. Typical: Python 10-50k ops/s, our Go server 40-100k, real Redis 50-200k. The architecture is identical. Implementation is the lever.

10-capstone/main.go
go
func runPhase(host string, port int, n, concurrency int, op string) result {
    perWorker := n / concurrency
    var latencies []time.Duration
    var mu sync.Mutex
    var wg sync.WaitGroup
    t0 := time.Now()
    for i := 0; i < concurrency; i++ {
        wg.Add(1)
        go func() { defer wg.Done(); worker(host, port, perWorker, op, &latencies, &mu) }()
    }
    wg.Wait()
    elapsed := time.Since(t0)
    sort.Slice(latencies, func(i, j int) bool { return latencies[i] < latencies[j] })
    return result{
        op: op, totalOps: len(latencies), elapsed: elapsed,
        throughput: float64(len(latencies)) / elapsed.Seconds(),
        p50:        latencies[len(latencies)/2],
        p99:        latencies[(len(latencies)*99)/100],
    }
}

Phased benchmark: per-worker goroutine, all do N/C ops, latencies collected and percentile sorted.

Where the gap to real Redis comes from

Architecture is identical. Constant-factor losses are net.Conn overhead, occasional GC pauses, no vectored writes.