node/benchmark
Matteo Collina fa2eaa54fb
stream: reduce allocations on WHATWG streams hot paths
Pure-JavaScript optimizations to lib/internal/webstreams/* that reduce
per-chunk and per-construction allocations on hot paths without
observable behavior change.

Per-chunk: reuse promise-reaction closures per controller, add buffered
fast path for async iterator, specialize callback wrappers by arity,
and share immutable nil records for writable stream resets.

Per-construction: use queueMicrotask for non-object start results,
materialize reader/writer .closed and .ready records lazily, and remove
dead allocations.

Assisted-by: Claude Fable 5
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/63876
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-06-20 14:19:08 +00:00
..
abort_controller benchmark: add AbortSignal.abort benchmarks 2024-04-10 20:16:04 +00:00
assert assert,util: handle invalid dates as equal in deep comparison 2025-06-21 04:00:23 +00:00
async_hooks lib: rewrite AsyncLocalStorage without async_hooks 2024-08-02 19:44:20 +00:00
blob benchmark: reduce the buffer size for blob 2024-04-17 19:33:44 +00:00
buffers src: add Latin1 fast path in StringBytes::Encode utf8 2026-06-01 07:05:25 +00:00
child_process benchmark: add child_process async path baselines 2026-06-17 16:08:56 +00:00
cluster benchmark: calibrate config cluster/echo.js 2025-09-12 12:59:37 +00:00
console console: optimize single-string logging 2025-11-02 23:33:58 +00:00
crypto crypto: use EVP_MAC for HMAC on OpenSSL >=3 2026-06-19 07:50:57 +00:00
dgram benchmark: fix destructuring in dgram/single-buffer 2026-03-16 18:16:39 +00:00
diagnostics_channel benchmark: reduce N for diagnostics_channel subscribe benchmark 2025-07-20 20:45:00 +00:00
dns
domain benchmark: update iterations of benchmark/domain/domain-fn-args.js 2024-03-04 10:05:28 +00:00
error errors: fix stacktrace of SystemError 2023-12-23 09:04:45 -08:00
es benchmark: remove deprecated _extend from benchmark 2025-08-11 15:42:46 +00:00
esm benchmark: use typescript for import cjs benchmark 2025-11-12 18:34:59 +00:00
events events: optimize EventTarget.addEventListener 2024-10-14 10:24:32 +00:00
ffi ffi: add experimental fast FFI call API for AArch64 and x86_64 2026-06-16 09:35:02 +00:00
fixtures module: remove --experimental-transform-types 2026-02-27 16:32:43 +00:00
fs src: dispatch ToV8Value(string_view) via StringBytes::Encode 2026-05-27 21:30:47 +02:00
http http: implement slab allocation for HTTP header parsing 2026-02-04 14:11:00 +00:00
http2
https
internal lib,src: isInsideNodeModules should test on the first non-internal frame 2025-12-10 13:59:35 +00:00
mime
misc lib: refactor internal webidl converters 2026-05-04 15:21:45 +00:00
module benchmark: add per-suite setup option 2025-11-07 17:47:43 +00:00
napi node-api: fix node_api_create_object_with_properties name 2026-01-23 03:51:23 +00:00
net stream: bump default highWaterMark 2024-03-13 19:02:14 +00:00
os os: improve tmpdir performance 2024-09-11 14:46:30 +00:00
path path: improve path.resolve() performance when used as process.cwd() 2025-05-19 13:23:57 +00:00
perf_hooks benchmark: add nodeTiming.uvmetricsinfo bench 2024-11-01 13:35:15 -03:00
permission benchmark: update count to n in permission startup 2025-09-24 20:33:10 +00:00
process process: optimize asyncHandledRejections by using FixedQueue 2026-01-02 11:40:05 +00:00
querystring
readline
source_map benchmark: add source map and source map cache 2025-07-07 15:53:35 +00:00
sqlite benchmark: add SQLite benchmarks 2026-01-23 19:14:29 +01:00
streams stream: use data listener for compose forwarding 2026-05-29 07:59:57 +00:00
string_decoder benchmark: adjust configuration for string-decoder bench 2025-07-25 20:49:56 +00:00
test_runner test_runner: run single test file benchmark 2025-01-09 11:12:12 +00:00
timers
tls tls: remove deprecated tls.createSecurePair 2025-03-11 23:01:28 +00:00
ts module: remove --experimental-transform-types 2026-02-27 16:32:43 +00:00
url url: optimize URLSearchParams set/delete duplicate handling 2026-04-26 09:04:48 +00:00
util util: create hex style cache and fast path 2026-05-29 19:43:34 +00:00
v8 lib: avoid quadratic shift() in startup snapshot callback 2026-04-27 23:17:57 +09:00
validators lib: improve performance of validateStringArray and validateBooleanArray 2023-10-22 21:12:38 +00:00
vm benchmark: add benchmark for leaf source text modules 2025-10-18 08:20:47 +00:00
websocket lib: enable WebSocket by default 2024-02-04 14:03:39 +00:00
webstorage src: unflag --experimental-webstorage by default 2025-09-25 11:59:58 +00:00
webstreams stream: reduce allocations on WHATWG streams hot paths 2026-06-20 14:19:08 +00:00
worker
zlib zlib: implement fast path for crc32 2025-09-14 00:39:58 +00:00
_benchmark_progress.js
_cli.js benchmark: small lint fix on _cli.js 2025-07-24 17:17:52 +00:00
_cli.R
_http-benchmarkers.js lib: prefer logical assignment 2024-10-09 06:42:16 +00:00
_test-double-benchmarker.js
bar.R
calibrate-n.js benchmark: add calibrate-n script 2025-07-29 18:49:55 +00:00
common.js benchmark: allow boolean option values 2025-12-25 10:45:06 +00:00
compare.js benchmark: inherit stdio/stderr instead of pipe 2024-04-13 18:01:28 +00:00
compare.R
cpu.sh benchmark: improve cpu.sh for safety and usability 2025-10-27 14:10:27 +00:00
eslint.config_partial.mjs tools: import rather than require ESLint plugins 2025-03-07 14:52:52 +00:00
README.md benchmark,doc: mention bar.R to the list of scripts 2024-09-04 18:53:02 +00:00
run.js benchmark: add --track to benchmark 2025-07-25 13:22:26 +00:00
scatter.js
scatter.R

Node.js Core Benchmarks

This folder contains code and data used to measure performance of different Node.js implementations and different ways of writing JavaScript run by the built-in JavaScript engine.

For a detailed guide on how to write and run benchmarks in this directory, see the guide on benchmarks.

Table of Contents

File tree structure

Directories

Benchmarks testing the performance of a single node submodule are placed into a directory with the corresponding name, so that they can be executed by submodule or individually. Benchmarks that span multiple submodules may either be placed into the misc directory or into a directory named after the feature they benchmark. E.g. benchmarks for various new ECMAScript features and their pre-ES2015 counterparts are placed in a directory named es. Fixtures that are not specific to a certain benchmark but can be reused throughout the benchmark suite should be placed in the fixtures directory.

Other Top-level files

The top-level files include common dependencies of the benchmarks and the tools for launching benchmarks and visualizing their output. The actual benchmark scripts should be placed in their corresponding directories.

  • _benchmark_progress.js: implements the progress bar displayed when running compare.js
  • _cli.js: parses the command line arguments passed to compare.js, run.js and scatter.js
  • _cli.R: parses the command line arguments passed to compare.R
  • _http-benchmarkers.js: selects and runs external tools for benchmarking the http subsystem.
  • bar.R: R script for visualizing the output of benchmarks with bar plots.
  • common.js: see Common API.
  • compare.js: command line tool for comparing performance between different Node.js binaries.
  • compare.R: R script for statistically analyzing the output of compare.js
  • run.js: command line tool for running individual benchmark suite(s).
  • scatter.js: command line tool for comparing the performance between different parameters in benchmark configurations, for example to analyze the time complexity.
  • scatter.R: R script for visualizing the output of scatter.js with scatter plots.

Common API

The common.js module is used by benchmarks for consistency across repeated tasks. It has a number of helpful functions and properties to help with writing benchmarks.

createBenchmark(fn, configs[, options])

See the guide on writing benchmarks.

default_http_benchmarker

The default benchmarker used to run HTTP benchmarks. See the guide on writing HTTP benchmarks.

PORT

The default port used to run HTTP benchmarks. See the guide on writing HTTP benchmarks.

sendResult(data)

Used in special benchmarks that can't use createBenchmark and the object it returns to accomplish what they need. This function reports timing data to the parent process (usually created by running compare.js, run.js or scatter.js).