GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Hono JSON serving through four cluster workers over TCP on WSL2 takes 24% longer in Bun 1.4.2 than Node for the first 25,000 requests per worker (1.14 s vs 0.92 s) · Issue #44791 · oven-sh/bun

Hono JSON serving through four cluster workers over TCP on WSL2 takes 24% longer in Bun 1.4.2 than Node for the first 25,000 requests per worker (1.14 s vs 0.92 s) #44791

New issue
Copy link
New issue
Copy link
Open
Open
Hono JSON serving through four cluster workers over TCP on WSL2 takes 24% longer in Bun 1.4.2 than Node for the first 25,000 requests per worker (1.14 s vs 0.92 s)#44791
Copy link
Labels
bugSomething isn't workingneeds triage

Description

@bompus
bompus
opened on Oct 8, 2026
Issue body actions

What version of Bun is running?

1.4.2+744846f844374847c902b5e7fd59b4342a51ef99

What platform is your computer?

Linux 7.2.9-locietta-WSL2-xanmod1 x86_64 GNU/Linux; WSL2; Node 26.11.1

What steps can reproduce the bug?

Hono Node-adapter four-worker JSON route over TCP on WSL2 takes 24% longer in Bun 1.4.2 than Node 26.11.1 for the first 25,000 requests per worker

The earlier report was created 2023-11-19, before the Bun 1.4.0 cutoff. This linked current-version report retains the measured reproduction and limitations below. Existing evidence: #7224 (comment)

Current-stable follow-up to the invitation to report another slower Bun case.

With the same Hono Node adapter on both runtimes, this four-worker TCP JSON route took about 24% longer under Bun. This tests the adapter configuration, not Hono's Bun-native adapter or a universal framework ranking.

Versions: Node 26.11.1; Bun 1.4.2 (744846f); Hono 4.6.4; @hono/node-server 1.13.2; oha 1.16.0. Linux x86_64, WSL2, kernel 7.2.9-locietta-WSL2-xanmod1.

Five fresh-process runs per runtime, balanced runtime order. Each run validated all four workers, performed 1,000 validated warmup requests, then measured 100,000 requests with 32 concurrent connections. Oha used persistent connections for the timed load. Warmup used serial requests with connection close.

Metric Node median [range] Bun median [range]
Load elapsed (s) 0.919216 [0.908761, 0.983563] 1.139396 [1.115533, 1.160169]
Mean response latency (ms) 0.291255 [0.287688, 0.311808] 0.361389 [0.353772, 0.368187]
Sampled server/worker RSS (MiB) 446.320 [442.891, 449.410] 367.910 [365.227, 369.980]

All ten runs completed with the expected response counts, HTTP 200 responses and no request errors. Both elapsed ranges were disjoint and within the preset 10% span criterion. Bun used less sampled server memory in this case.

Server/worker affinity was CPUs 0-3; oha used CPUs 4-7 and four processing workers. Nice was 10 throughout, under a 2 GiB whole-phase cap. No memory-limit or OOM events occurred. Sources, dependencies and runtimes were read-only during collection.

The outer observer retained CPU, pressure, thread, process and memory measurements. This case had no provisional resource flags. Missing short-lived identities, final writeback and shared-provider costs remain gaps. Observer sensitivity was not calibrated, so this is an observed-method result, not proof of negligible observer impact or an engine cause.

A separate bare node:http control did not establish a consistent Node advantage under the same preset variation criterion. It does not isolate this result to the HTTP engine. The 300-connection Hono case also failed the variation criterion; it is not included in the 24% claim.

This fresh report tracks the current matched Node-adapter case and links the older closed report.

The following are the exact public-only sources used for these measurements. The HTTP harness retains its measured server/client CPU partition internally; the outer commands need no scheduling wrapper. Save them in one directory and install the pinned package.json dependencies. No application services or external data are required.

export OHA_BINARY="$(command -v oha)"
export BENCH_MODE=timing BENCH_REQUESTS=100000 BENCH_HTTP_WARMUP_REQUESTS=1000
# Alternate these commands over five rounds, starting with Bun on odd rounds.
node runtime-comparison.js hono tcp 4 32
bun runtime-comparison.js hono tcp 4 32
package.json
{
  "private": true,
  "type": "module",
  "dependencies": {
    "fastify": "5.0.0",
    "hono": "4.6.4",
    "@hono/node-server": "1.13.2"
  }
}
runtime-comparison.js
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { spawn } from 'node:child_process';
import { createInterface } from 'node:readline';
import { once } from 'node:events';
import http from 'node:http';
import net from 'node:net';
import { processControls, processPeakRss } from './controls.mjs';

const [framework, transport, workerCount = '1', concurrency = '32'] = process.argv.slice(2);
const mode = process.env.BENCH_MODE ?? 'check';
assert.ok(['check', 'timing'].includes(mode));
const workers = Number(workerCount),
  clients = Number(concurrency);
assert.ok(Number.isInteger(clients) && clients > 0 && clients <= 300);
const operations = Number(process.env.BENCH_REQUESTS ?? 100000);
assert.ok(Number.isSafeInteger(operations) && operations > 0);
const warmupRequests = Number(process.env.BENCH_HTTP_WARMUP_REQUESTS ?? 0);
assert.ok(Number.isSafeInteger(warmupRequests) && warmupRequests >= 0);
const requestPath = process.env.BENCH_HTTP_PATH ?? '/bench/?q=q1';
assert.ok(requestPath.startsWith('/') && !requestPath.includes('\n'));
const expectedFile = process.env.BENCH_HTTP_EXPECTED_FILE;
const expectedBody = expectedFile ? fs.readFileSync(expectedFile, 'utf8') : null;
const socketRoot = process.env.BENCH_SOCKET_ROOT;
let address;
if (transport === 'tcp') {
  const listener = net.createServer();
  listener.listen(0, '127.0.0.1');
  await once(listener, 'listening');
  address = String(listener.address().port);
  await new Promise((resolve) => listener.close(resolve));
} else {
  assert.ok(socketRoot, 'Set BENCH_SOCKET_ROOT to a private disk-backed directory');
  fs.mkdirSync(socketRoot, { recursive: true });
  address = path.join(socketRoot, `http-${process.pid}.sock`);
  assert.ok(Buffer.byteLength(address) < 104, 'Unix socket path too long');
  assert.ok(!fs.existsSync(address));
}
const environment = { ...process.env, LRU_EXPECTED_AFFINITY: '0-3' };
const args = [
  '-c',
  '0-3',
  process.execPath,
  ...(globalThis.Bun ? ['--no-env-file', '--no-install'] : []),
  new URL('./server.mjs', import.meta.url).pathname,
  framework,
  transport,
  address,
  workerCount
];
const server = spawn('/usr/bin/taskset', args, { env: environment, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
const serverClosed = new Promise((resolve) => server.once('close', resolve));
async function stop(child, closed) {
  if (!child?.pid) return;
  const signalGroup = (signal) => {
    try {
      process.kill(-child.pid, signal);
    } catch (error) {
      if (error.code !== 'ESRCH') throw error;
    }
  };
  signalGroup('SIGTERM');
  let timer;
  const stopped = await Promise.race([
    closed.then(() => true),
    new Promise((resolve) => {
      timer = setTimeout(() => resolve(false), 5000);
    })
  ]);
  clearTimeout(timer);
  if (!stopped) {
    signalGroup('SIGKILL');
    await closed;
    throw Error(`Process group ${child.pid} required forced cleanup`);
  }
}
let stderr = '',
  ready,
  sampleTimer,
  client,
  clientClosed;
let cleanupPromise;
function cleanup() {
  return (cleanupPromise ??= (async () => {
    clearInterval(sampleTimer);
    const stopped = await Promise.allSettled([client && client.exitCode === null ? stop(client, clientClosed) : Promise.resolve(), stop(server, serverClosed)]);
    if (transport === 'unix') fs.rmSync(address, { force: true });
    for (const outcome of stopped) if (outcome.status === 'rejected') throw outcome.reason;
  })());
}
for (const [signal, exitCode] of [
  ['SIGTERM', 143],
  ['SIGINT', 130]
]) {
  process.once(signal, () => {
    cleanup().then(
      () => process.exit(exitCode),
      (error) => {
        console.error(error);
        process.exit(1);
      }
    );
  });
}
const lines = [];
server.stderr.on('data', (data) => {
  stderr += data;
});
const reader = createInterface({ input: server.stdout });
const readyPromise = new Promise((resolve, reject) => {
  reader.on('line', (line) => {
    try {
      const record = JSON.parse(line);
      lines.push(record);
      if (record.ready) {
        ready = record;
        resolve(record);
      }
    } catch {}
  });
  server.once('error', reject);
  server.once('exit', (code) => {
    if (!ready) reject(Error(`Server exited ${code}: ${stderr}`));
  });
});
let peakServerRssBytes = 0;
const samples = [];
function sample() {
  if (!ready) return;
  const pids = [...new Set([server.pid, ...ready.workers.map((worker) => worker.pid)])];
  let rss = 0;
  for (const pid of pids) {
    try {
      rss += Number(/^VmRSS:\s+(\d+) kB$/m.exec(fs.readFileSync(`/proc/${pid}/status`, 'utf8'))?.[1] ?? 0) * 1024;
    } catch (error) {
      if (error.code !== 'ENOENT') throw error;
    }
  }
  peakServerRssBytes = Math.max(peakServerRssBytes, rss);
  samples.push({ at: performance.now(), rssBytes: rss });
}
async function request() {
  return new Promise((resolve, reject) => {
    const req = http.get(
      {
        hostname: '127.0.0.1',
        port: transport === 'tcp' ? Number(address) : undefined,
        socketPath: transport === 'unix' ? address : undefined,
        path: requestPath,
        agent: false,
        headers: { Host: '127.0.0.1', Connection: 'close' }
      },
      (reply) => {
        let body = '';
        reply.setEncoding('utf8');
        reply.on('data', (data) => {
          body += data;
        });
        reply.on('end', () => {
          try {
            assert.equal(reply.statusCode, 200);
            if (expectedFile) assert.equal(body, expectedBody);
            else assert.deepEqual(JSON.parse(body), { a: 'b', q: 'q1' });
            assert.equal(reply.headers['x-message'], 'hi');
            resolve(reply.headers['x-worker']);
          } catch (error) {
            reject(error);
          }
        });
        reply.on('error', reject);
      }
    );
    req.setTimeout(2000, () => req.destroy(Error('Qualification request timed out')));
    req.on('error', reject);
  });
}
let result;
try {
  await Promise.race([
    readyPromise,
    new Promise((_, reject) => {
      const timer = setTimeout(() => reject(Error('Server startup timeout')), 10000);
      timer.unref();
    })
  ]);
  for (const worker of ready.workers) {
    assert.deepEqual(worker.runtime, process.versions, 'Worker must use the selected runtime');
    assert.equal(worker.bunRevision, globalThis.Bun?.revision ?? null);
  }
  const seen = new Set();
  for (let i = 0; i < Math.max(1, workers * 25); i++) {
    seen.add(await request());
    if (seen.size === workers) break;
  }
  assert.deepEqual([...seen].sort(), ready.workers.map((worker) => String(worker.pid)).sort(), 'Every worker must answer');
  // Equal, validated route invocations before the measured load; default preserves old cohorts.
  for (let i = 0; i < warmupRequests; i++) await request();
  sample();
  sampleTimer = setInterval(sample, 20);
  let load;
  if (mode === 'timing') {
    const oha = process.env.OHA_BINARY;
    assert.ok(oha && path.isAbsolute(oha), 'Set OHA_BINARY to the pinned executable');
    const argv = [
      '-c',
      '4-7',
      oha,
      '--output-format',
      'json',
      '--no-tui',
      '--worker-threads',
      '4',
      '-t',
      '10s',
      '-n',
      String(operations),
      '-c',
      String(clients),
      '-H',
      'Host: 127.0.0.1',
      ...(transport === 'unix' ? ['--unix-socket', address] : []),
      `http://127.0.0.1:${transport === 'tcp' ? address : '80'}${requestPath}`
    ];
    client = spawn('/usr/bin/taskset', argv, { detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
    clientClosed = new Promise((resolve) => client.once('close', resolve));
    let stdout = '',
      clientError = '';
    client.stdout.on('data', (data) => {
      stdout += data;
    });
    client.stderr.on('data', (data) => {
      clientError += data;
    });
    const [code] = await once(client, 'close');
    assert.equal(code, 0, clientError);
    load = JSON.parse(stdout);
    assert.equal(load.summary.successRate, 1, 'HTTP load must complete without failures');
    assert.equal(load.statusCodeDistribution['200'], operations, 'Request counts must match');
    await request();
  }
  sample();
  result = {
    mode,
    framework,
    transport,
    workers,
    clients,
    operations: mode === 'timing' ? operations : 0,
    warmupRequests,
    requestPath,
    warmupMethod: 'Serial validated HTTP requests with connection close, before load timing and RSS sampling',
    runtime: process.versions,
    bunRevision: globalThis.Bun?.revision ?? null,
    correctness: true,
    controls: processControls(),
    ...processPeakRss(),
    ready,
    load,
    peakServerRssBytes,
    serverRssMethod: '20ms sum of live server/worker RSS; shared pages counted per process; sampled peak lower bound',
    samples
  };
} catch (error) {
  if (stderr) console.error(stderr);
  throw error;
} finally {
  await cleanup();
}
result.stopped = lines.filter((record) => record.stopped);
if (process.env.BENCH_OUTPUT) fs.writeFileSync(process.env.BENCH_OUTPUT, JSON.stringify(result, null, 2) + '\n');
else console.log(JSON.stringify(result));
server.mjs
import assert from 'node:assert/strict';
import cluster from 'node:cluster';
import { once } from 'node:events';
import { processControls, processPeakRss } from './controls.mjs';
const [framework, transport, address, count = '1'] = process.argv.slice(2);
const workers = Number(count);
assert.ok(['fastify', 'hono'].includes(framework));
assert.ok(['tcp', 'unix'].includes(transport));
assert.ok(Number.isInteger(workers) && workers >= 1 && workers <= 4);
const target = transport === 'tcp' ? {port:Number(address),host:'127.0.0.1'} : {path:address};
let close, stopping = false;
async function shutdown() {
  if (stopping) return;
  stopping = true;
  if (cluster.isPrimary && workers > 1) {
    const children = Object.values(cluster.workers);
    const exits = children.map(worker => once(worker, 'exit'));
    for (const worker of children) worker.process.kill('SIGTERM');
    await Promise.all(exits);
  } else await close?.();
  console.log(JSON.stringify({stopped:true,controls:processControls(),...processPeakRss(),cpu:process.cpuUsage()}));
  process.exit(process.exitCode ?? 0);
}
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
if (cluster.isPrimary && workers > 1) {
  cluster.setupPrimary({exec:new URL(import.meta.url).pathname,args:process.argv.slice(2)});
  const ready = [];
  for (let index = 0; index < workers; index++) {
    const worker = cluster.fork();
    worker.on('exit', code => {if (!stopping) { console.error(`Worker exited: ${code}`); process.exitCode=1; shutdown(); }});
    ready.push(new Promise(resolve => worker.once('message',resolve)));
  }
  const children = await Promise.all(ready);
  console.log(JSON.stringify({ready:true,workers:children,controls:processControls()}));
} else {
  if (framework === 'fastify') {
    const {default:fastify} = await import('fastify');
    const app = fastify({keepAliveTimeout:61000});
    app.get('/bench/', async (request,reply) => {reply.header('X-Message','hi');return await {a:'b',q:request.query.q};});
    app.addHook('onRequest',async (_request,reply) => {reply.header('X-Worker',String(process.pid));});
    await app.listen(target);close=()=>app.close();
  } else {
    const {Hono} = await import('hono');
    const {createAdaptorServer} = await import('@hono/node-server');
    const app = new Hono();
    app.get('/bench/',async context => {context.header('X-Message','hi');context.header('X-Worker',String(process.pid));return context.json(await {a:'b',q:context.req.query('q')});});
    const server=createAdaptorServer({fetch:app.fetch});server.listen(target);await once(server,'listening');
    close=()=>new Promise((resolve,reject)=>server.close(error=>error?reject(error):resolve()));
  }
  const ready={pid:process.pid,controls:processControls(),runtime:process.versions,bunRevision:globalThis.Bun?.revision??null};
  if (cluster.isWorker) process.send(ready);else console.log(JSON.stringify({ready:true,workers:[ready],controls:processControls()}));
}
controls.mjs
import fs from 'node:fs';
import os from 'node:os';

export function processControls() {
  const nice = os.getPriority();
  const cpuAffinity = process.platform === 'linux'
    ? /^Cpus_allowed_list:\s*(.+)$/m.exec(fs.readFileSync('/proc/self/status', 'utf8'))?.[1] ?? null : null;
  if (process.env.LRU_EXPECTED_NICE !== undefined && nice !== Number(process.env.LRU_EXPECTED_NICE)) {
    throw new Error(`Unexpected benchmark nice value ${nice}`);
  }
  if (process.env.LRU_EXPECTED_AFFINITY !== undefined && cpuAffinity !== process.env.LRU_EXPECTED_AFFINITY) {
    throw new Error(`Unexpected benchmark CPU affinity ${cpuAffinity}`);
  }
  return { pid: process.pid, nice, cpuAffinity };
}

export function processPeakRss() {
  // Linux getrusage retains peaks across exec; VmHWM belongs to this address space.
  if (process.platform === 'linux') {
    const match = /^VmHWM:\s+(\d+) kB$/m.exec(fs.readFileSync('/proc/self/status', 'utf8'));
    if (!match) throw new Error('Missing VmHWM in /proc/self/status');
    return { processPeakRssBytes: Number(match[1]) * 1024, peakRssSource: 'Linux VmHWM' };
  }
  return { processPeakRssBytes: process.resourceUsage().maxRSS * 1024, peakRssSource: 'process.resourceUsage; may include launcher history' };
}

What is the expected behavior?

The same correctly responding Hono Node-adapter configuration should not consistently take longer under Bun.

What do you see instead?

Serving 100,000 JSON requests (25,000 per worker) through four Hono cluster workers over TCP on WSL2 takes 1.14 s in Bun 1.4.2 against 0.92 s in Node 26.11.1, 24% longer (five runs each, preset variation criterion met). This window includes JavaScriptCore warm-up and WSL2 loopback cost; a one-process Unix-socket rerun with 1,000,000 requests did not show Bun slower. See the comment of 2026-10-19 below for what that does and does not show.

Hono JSON serving through four cluster workers takes 24% longer in Bun. Load elapsed: 0.919 s to 1.14 s, 24% slower; Mean response latency: 0.291 ms to 0.361 ms, 24% slower; Sampled server and worker RSS: 446 MiB to 368 MiB, 18% lower.

Chart data as text
Metric Node 26 Bun 1.4.2 Change
Load elapsed 0.919 s 1.14 s 24% slower
Mean response latency 0.291 ms 0.361 ms 24% slower
Sampled server and worker RSS 446 MiB 368 MiB 18% lower

For 100,000 requests/concurrency 32, median load elapsed was 1.139396s under Bun versus 0.919216s under Node. All 10 runs completed with expected responses and no request errors; ranges were disjoint under the preset criterion.

Additional information

Fresh linked current-version report for closed #7224. User directs refiling older closed reports. Prior current evidence is linked in the reproduction. Sources/versions/correctness/repetitions/control flags and uncalibrated observer limits are disclosed; no internal cause or universal ranking is claimed.

Activity

  1. bompus
    added
    bugSomething isn't working
    needs triage
    on Oct 8, 2026
  2. bompus commented on Oct 8, 2026

    @bompus
    bompus
    on Oct 8, 2026
    Author
    More actions

    I tested a separate adapter/route reduction on Node 26.11.1 and Bun 1.4.2. It does not reproduce this report's four-worker HTTP slowdown.

    Mock case Node ns/op Bun ns/op
    Hono route through getRequestListener 1124.844 1048.946
    Bare handler through getRequestListener 701.436 557.083
    Bare Response body consumption 3072.540 847.687
    Direct JSON.stringify + URL query 219.524 224.400

    Five balanced rounds used fresh processes and exact status/body checks. The 3 adapter/Response cases favor Bun and meet the preset run-span criterion. Direct JSON/URL overlaps and fails that criterion; it is inconclusive. This is a new cohort, separate from the original HTTP samples, with no pooling or quality-driven rerun.

    Both adapter cases share the adapter's supported global Request/Response wrappers. The timed mock also includes status assertions in both adapter cases. It omits actual sockets, HTTP parsing, transport backpressure and cluster scheduling. Those omissions make this a negative isolation result, not a substitute for the original HTTP benchmark.

    I cannot attribute the original result to JSON, URL, Request/Response or Hono route/context work based on this reduction. The real HTTP/cluster/transport context remains necessary to investigate. No internal engine cause is confirmed, and the original report's reproduction and measurements remain unchanged.

  3. bompus
    changed the title [-]Hono Node-adapter four-worker JSON route takes 24% longer in Bun 1.4.2 than Node 26.11.1[/-] [+]Hono Node-adapter JSON serving through four cluster workers takes longer than Node[/+] on Oct 8, 2026
  4. bompus commented on Oct 10, 2026

    @bompus
    bompus
    on Oct 10, 2026
    Author
    More actions

    Another data point from a different server. A Fastify 4.26.1 route in one process over TCP loopback also takes longer under Bun 1.4.2 than under Node 26.11.1. The same route over a Unix socket does not.

    Versions: Node 26.11.1; Bun 1.4.2 (744846f); Fastify 4.26.1; oha 1.16.0; Linux 7.2.9 (WSL2, x86_64).

    Setup: one server process, 32 connections, four oha workers, 1,000 warmup requests, then 100,000 timed requests to a small JSON route. 20 paired rounds with alternating runtime order. Ratio is Bun total time divided by Node total time (above 1 means Bun is slower). The interval runs from the 6th to the 15th of the 20 sorted ratios.

    Transport Median ratio Interval Rounds Bun slower
    Unix socket 0.704 0.672 to 0.758 0 of 20
    TCP 127.0.0.1, first run 1.168 1.067 to 1.383 15 of 20
    TCP 127.0.0.1, rerun with simpler scripts 1.133 1.059 to 1.300 17 of 20

    In the rerun, Bun 1.4.3 gave 1.091 (0.965 to 1.193), and a plain node:http handler with the same JSON and headers gave 1.056 (0.977 to 1.147) on Bun 1.4.2. So I cannot say whether the extra time comes from Fastify or from the HTTP layer underneath it.

    Limits: round-to-round scatter was large (20.7% in the first run). The lower end of the rerun interval is only 0.9 points above a 5% gap. Everything ran on one WSL2 host with mirrored networking, where 127.0.0.1 is routed through a host loopback interface (a one-byte echo round trip takes about 240 µs), and I have not tried it outside WSL2. This is also a different configuration from this issue (one process instead of four, Fastify instead of the Hono adapter), so it does not confirm the 24% here. I can share the scripts and raw timings if they would help.

  5. bompus
    changed the title [-]Hono Node-adapter JSON serving through four cluster workers takes longer than Node[/-] [+]Hono JSON serving through four cluster workers takes 24% longer than Node (1.14 s vs 0.92 s)[/+] on Oct 12, 2026
  6. robobun commented on Oct 18, 2026

    @robobun
    robobun
    on Oct 18, 2026
    Collaborator
    More actions

    I measured this on plain Linux x64 (a KVM guest, no WSL2) with Node.js v26.11.1 and bun 1.4.2, 1.4.3 and the canary build 5f5799ed1. The gap is real for the window that the report measures. It has three parts. None of them is TCP or node:cluster.

    Method. The server uses builtin modules only. It makes the same node:http calls that @hono/node-server 1.13.2 makes for this route (I did not run Hono itself). The shape is the one of the report: 4 cluster workers on CPUs 0-3, oha 1.16.0 with 4 threads on CPUs 4-7, 32 connections, 1,000 warm-up requests, 100,000 timed requests. Elapsed time on my host differs by a factor of 2 between rounds. So I counted the instructions of the server processes with perf_event_open, in 10 interleaved rounds.

    Per request, median Instructions Request threads (user) Other threads (user)
    Node.js v26.11.1 106,603 57,926 31,438
    bun 1.4.2 141,727 (+33%) 49,928 62,233
    bun 1.4.3 137,730 (+29%) 50,015 61,663
    bun canary 5f5799ed1 126,936 (+19%) 46,895 55,519

    1. bun 1.4.2 only: a thread wake-up each time the event loop sleeps. With one connection the loop sleeps after every request. There bun 1.4.2 makes 1.78 futex calls per request, and Node.js makes 0.04. #44560 stopped that wake-up of the allocator's background thread, and bun 1.4.3 makes 0.15. Your TCP path has a 240 µs round trip, so the loop sleeps after almost every request on TCP and almost never on a Unix socket. That fits your Fastify numbers: 0.70 on the Unix socket, 1.13 to 1.17 on TCP with 1.4.2, 1.09 with 1.4.3.

    2. The first requests of a new process pay for the JIT. In the table, the threads that serve requests do less work in bun than in Node.js. The "other threads" are mostly the JIT compiler. In a new process, JavaScriptCore's top tier compiles the node:http path during the first 50,000 requests. That costs about 1.3e9 to 1.6e9 instructions per process, against 0.9e9 for V8. The harness gives 4 workers and all their helper threads 4 CPUs, so the compiler takes CPU time from the request loops. The timed window is 25,000 requests per worker. The compiled code pays for itself after roughly 80,000. With 1,000,000 timed requests in the same shape the two runtimes are level: 68,160 against 69,799 instructions per request, elapsed ratio 1.02. As a check only: with the top tier off (BUN_JSC_useFTLJIT=0) the 100,000-request window takes 19% fewer instructions than Node.js.

    3. The end of each request still follows Node.js v26.3.0. For a keep-alive GET that nothing reads, bun queues 9 process.nextTick entries. Node.js v26.3.0 queues 10, and v26.11.1 queues 4 (nodejs/node#65310, nodejs/node#65749, nodejs/node#65732). Release builds of main (0ffddcdc6d), same shape:

    Ticks per GET User instructions per request
    main 9 110,386
    with #45098 7 99,865
    with #45098 and a port of nodejs/node#65732 5 95,113
    Node.js v26.11.1 4 90,755

    #45098 is open. #45234 (open) removes other work on the same path. The port of nodejs/node#65732 is a prototype on the branch robobun/e53df5cc/http-fast-forward-unread-teardown. It is not a pull request yet. It needs #45098 first, and a maintainer has to decide how _dump() ends such a request: the draft #45631 changes the same statement in another way.

    What did not matter. Both runtimes make one recv or read and one send or write per request, and about the same number of epoll calls. TCP and a Unix socket cost about the same user instructions. The spread of the 32 connections over the 4 workers is similar in both runtimes.

    A timed phase of 100,000 or more requests for each worker measures the server and not the compiler.

    Details

    Handler. adapter is the reduction of the calls of @hono/node-server 1.13.2 (getRequestListener, newRequest, responseViaCache):

    async function adapter(incoming, outgoing) {
      const host = incoming.headers.host;
      const url = new URL(`${incoming.socket && incoming.socket.encrypted ? "https" : "http"}://${host}${incoming.url}`);
      outgoing.on("close", () => {
        if (incoming.errored) throw incoming.errored;
      });
      const method = incoming.method || "GET";
      const href = url.href;
      const q = href.slice(href.indexOf("?q=") + 3);
      const body = JSON.stringify(await { a: "b", q });
      const header = { "x-message": "hi", "x-worker": pid, "content-type": "application/json; charset=UTF-8" };
      header["Content-Length"] = Buffer.byteLength(body);
      outgoing.writeHead(200, header);
      outgoing.end(body);
    }

    Counters. Instructions and cycles come from perf_event_open counters on the server process tree (user and kernel apart, one counter set for each thread for the split by thread). Snapshots before and after the timed load give the numbers for the window. The hypervisor took 12% to 80% of the CPU time of this guest, which is why elapsed time is not in the tables. In the first table the elapsed medians were 6.6 s (Node.js), 11.5 s (1.4.2), 8.2 s (1.4.3) and 7.6 s (canary), with ranges that overlap.

    Warm-up of one process (one worker, 32 connections, a plain writeHead and end handler). Request thread, user instructions per request in each window, and instructions of all other threads so far:

    Requests so far Node.js v26.11.1 Other threads bun canary Other threads
    1,000 157,458 110 M 132,866 158 M
    5,000 61,714 232 M 45,362 428 M
    10,000 50,746 325 M 38,155 925 M
    20,000 45,936 828 M 34,325 1,201 M
    50,000 41,249 898 M 32,723 1,585 M
    100,000 40,881 904 M 32,363 1,615 M
    500,000 40,711 966 M 32,123 1,754 M

    Syscalls for each request (strace -f -c, difference between a run of 60,000 and a run of 20,000 requests, one worker, 32 connections). Node.js: read 1.00, write 1.00, epoll_pwait 0.03, futex 0.04. bun canary: recvfrom 1.00, sendto 1.00, epoll_pwait2 0.03, futex 0.08, madvise 0.04. With 4 workers: epoll_pwait 0.18 (Node.js) and epoll_pwait2 0.17 (bun).

    TCP against a Unix socket (one process, 100,000 requests, user instructions per request). Node.js: 50,947 and 51,312. bun canary: 46,900 and 49,256.

    Connections for each worker (32 keep-alive connections from oha, 10 to 12 trials). Node.js: the busiest worker has 10.5 in the median, the idlest 6. bun canary: 11 and 5.

    Ticks. process.nextTick is replaced by a counting wrapper before node:http loads. The count is for the server side of 200 keep-alive requests on one connection, after 20 warm-up requests.

    Other numbers for the table of part 3 (release builds of main, #45098, the prototype, and Node.js v26.11.1). Request thread at steady state, user instructions per request: 39,552, 38,643, 37,091 and 49,886. bench/snippets/http-hello.node.mjs, user instructions per request: 32,345, 29,403, 27,813 and 53,895.

  7. bompus commented on Oct 19, 2026

    @bompus
    bompus
    on Oct 19, 2026
    Author
    More actions

    Thank you for the instruction counts. They show two things I had not separated: the thread wake-up that only Bun 1.4.2 makes each time the event loop sleeps, and a timed window of 25,000 requests per worker that falls inside JavaScriptCore's warm-up. I measured on a Unix socket because on my host (WSL2 with mirrored networking) 127.0.0.1 traffic is routed through Windows, and my host's CPU rules would not accept a TCP run.

    What I measured. The route and harness files from this report, unchanged, but with one server process: with four cluster workers on a Unix socket the second worker fails with EADDRINUSE on Bun 1.4.3 and on the canary (#44794), and starts on Node. 32 connections, 1,000 warm-up requests, then 1,000,000 timed requests (the report used 100,000). Node 26.12.0, Bun 1.4.3 (c6da4a4) and canary 1.4.4-canary.1+6bb5dc195. Five rounds; each round ran all three runtimes once, in a rotating order. Server on CPUs 0-3, oha on CPUs 4-7, nice 10, 2 GiB memory cap. Fifteen runs passed my host's load, memory-pressure and swap checks; 14 more attempts were rejected because other jobs on the host were running and are not counted. Every counted run returned 1,000,000 HTTP 200 responses with no errors.

    Runtime Load time for 1,000,000 requests, median [min, max] Run span Mean latency, median Sampled server RSS, median [min, max]
    Node 26.12.0 49.3 s [45.2, 52.1] 14% 1.575 ms 137 MiB [135, 139]
    Bun 1.4.3 39.1 s [34.8, 41.6] 17% 1.249 ms 81 MiB [81, 83]
    Bun canary 6bb5dc1 34.8 s [33.3, 36.6] 9% 1.110 ms 72 MiB [71, 73]

    In every round Bun finished before Node (Bun 1.4.3 took 0.71 to 0.86 of Node's time in the same round, the canary 0.69 to 0.77), and the ranges do not overlap. But the run span of Node (14%) and of Bun 1.4.3 (17%) is above the 10% criterion I set in this report, so I am not giving a percentage as the result. The direction is the same in all five rounds; the size is not established. Memory is clearer: the sampled RSS ranges are within 3% and far apart. Rejected attempts were retried later, so the run order drifted from the planned rotation.

    What this means for the 24% in the title. On one process, over a Unix socket and a long timed phase, Bun was not slower than Node in these runs. That does not retract the 24% and does not confirm it. The 24% was measured over TCP on WSL2 with four workers and a window of 25,000 timed requests per worker, on Bun 1.4.2. On my host TCP loopback also costs CPU on the Windows side. This is exploratory, one run each, on a busy host, and not counted: with four workers and 1,000,000 requests the same Node server took 15.9 s over TCP and 5.8 s over the Unix socket, and Windows kernel DPC time was 14 to 17% of all CPUs over TCP and about 1% over the Unix socket. Together with your measurements, I cannot say how much of the original 24% belongs to the runtime and how much to the path and the warm-up. I am changing the title and the opening summary to say what the original run showed. The four-worker comparison, and TCP on a host without this loopback cost, stay open; I will rerun when #45186 is in a Bun build.

  8. bompus
    changed the title [-]Hono JSON serving through four cluster workers takes 24% longer than Node (1.14 s vs 0.92 s)[/-] [+]Hono JSON serving through four cluster workers over TCP on WSL2 takes 24% longer in Bun 1.4.2 than Node for the first 25,000 requests per worker (1.14 s vs 0.92 s)[/+] on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.