Capstone: Async benchmark vs real Redis

Node lands between Python and Go for this workload. V8 is fast but not C-fast. Run the bench, compare to real Redis on port 6379.

10-capstone/bench.mjs
javascript
async function worker(workerId, ops, op, latencies) {
  return new Promise((resolve) => {
    const conn = connect(port, host);
    let buf = Buffer.alloc(0);
    let pending = ops, outstanding = 0;
    const send = () => {
      if (pending <= 0) return;
      const key = `bench:${workerId}:${pending}`;
      const req = op === "SET" ? encodeArray(["SET", key, "x_x_x_x_x_x_x_x_"]) : encodeArray(["GET", key]);
      conn.write(req);
      latencies.push(process.hrtime.bigint());
      pending--; outstanding++;
    };
    conn.on("connect", send);
    conn.on("data", (chunk) => {
      buf = Buffer.concat([buf, chunk]);
      while (true) {
        const r = tryReadReply(buf);
        if (r === null) break;
        buf = buf.slice(r.consumed);
        const idx = latencies.length - outstanding;
        latencies[idx] = Number(process.hrtime.bigint() - latencies[idx]) / 1e6;
        outstanding--;
        if (pending > 0) send();
        else if (outstanding === 0) { conn.end(); resolve(); return; }
      }
    });
  });
}

Async worker pool. Each worker opens a conn, sends ops as fast as the previous reply lands, records latency.

Two numbers matter in the report. When the workers finish, the harness sorts the latencies array and reads positions from it: the middle element is p50, the element at the 99 percent mark is p99. p50 is the typical request, half were faster. p99 is the tail, only one request in a hundred was slower. Averages hide slow outliers, and p99 is where users actually feel the pain, which is why every serious benchmark reports it alongside throughput.

Three languages, same architecture

The gap is constant-factor: language, allocation, runtime. Architecture is identical.