GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 Open Labels DescriptionWhat 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.
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.jsimport 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.mjsimport 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.mjsimport 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. Chart data as text
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 informationFresh 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
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue 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. |