James M Snell
64c115072e
stream, quic: update iterable streams backpressure
...
Signed-off-by: James M Snell <jasnell@gmail.com >
Assisted-by: Opencode/Opus
PR-URL: https://github.com/nodejs/node/pull/64464
Reviewed-By: Tim Perry <pimterry@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2026-07-23 05:19:45 -07:00
Trivikram Kamat
40dc5a1dc4
stream: use data listener for compose forwarding
...
Forward Node.js tail stream data through a pipe-style data listener
instead of manually draining readable events. This keeps compose closer
to the stream pipe hot path while preserving backpressure with pause
and resume.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com >
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63593
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2026-05-29 07:59:57 +00:00
Trivikram Kamat
3b19867caa
benchmark: respect stream/iter broadcast backpressure
...
Only decrement the remaining byte count after a stream/iter broadcast
write is accepted. If writeSync() is blocked by strict backpressure,
fall back to the async write() path for the same chunk.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com >
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63314
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2026-05-18 10:42:45 +00:00
Trivikram Kamat
1f371fcffb
stream: add sync iterable fast path to pipeTo
...
Avoid normalizing sync iterable sources through from() when pipeTo()
has no transforms or signal and the writer can accept sync writes.
This keeps writes incremental while preserving async fallback for
values that still need it.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com >
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63318
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2026-05-17 23:06:55 +00:00
Trivikram Kamat
265679b5ac
stream: limit iter from sync iterable batches
...
Bound sync iterable normalization in from() and fromSync() to
FROM_BATCH_SIZE. This avoids unbounded batches for from() sync
iterable fallbacks and lets fromSync() coalesce plain Uint8Array
values for writev paths.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com >
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63324
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2026-05-17 08:04:30 +00:00
Trivikram Kamat
2edd842e2a
stream: cache minimum cursor count in share
...
Track the number of consumers at the cached minimum cursor in share()
so the minimum is only recomputed when the last consumer at that cursor
advances or detaches.
This avoids scanning every consumer on each trim attempt when multiple
consumers advance through a shared buffer.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com >
Assisted-by: openai:gpt-5.5
PR-URL: https://github.com/nodejs/node/pull/63262
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-05-14 20:51:54 +00:00
James M Snell
e78ccd8017
benchmark: add benchmarks for experimental stream/iter
...
Signed-off-by: James M Snell <jasnell@gmail.com >
Assisted-By: Claude/Opus 4.6
PR-URL: https://github.com/nodejs/node/pull/62066
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2026-03-27 19:55:35 -07:00
avcribl
4fe325d93d
stream: preserve AsyncLocalStorage on finished only when needed
...
PR-URL: https://github.com/nodejs/node/pull/59873
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Daniel Lemire <daniel@lemire.me >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-10-27 19:23:34 +00:00
jakecastelli
87ee722873
benchmark: add stream.compose benchmark
...
PR-URL: https://github.com/nodejs/node/pull/54308
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-08-12 12:40:04 +00:00
IlyasShabi
7d258db1d7
stream: support typed arrays
...
PR-URL: https://github.com/nodejs/node/pull/51866
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Raz Luvaton <rluvaton@gmail.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-03-20 17:27:29 +00:00
Robert Nagy
991fd9c255
stream: use Array for Readable buffer
...
PR-URL: https://github.com/nodejs/node/pull/50341
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-10-25 15:35:05 +00:00
Raz Luvaton
0fb512344f
benchmark: add more cases to Readable.from
...
PR-URL: https://github.com/nodejs/node/pull/50351
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br >
2023-10-24 01:36:17 +00:00
Robert Nagy
53b5545672
stream: writable state bitmap
...
PR-URL: https://github.com/nodejs/node/pull/49899
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Raz Luvaton <rluvaton@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2023-09-29 18:13:44 +00:00
Antoine du Hamel
ca5f322d32
benchmark: add trailing commas
...
PR-URL: https://github.com/nodejs/node/pull/46370
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-01-29 19:13:35 +01:00
SindreXie
869460aa58
benchmark: add stream destroy benchmark
...
PR-URL: https://github.com/nodejs/node/pull/44533
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Erick Wendel <erick.workspace@gmail.com >
2022-09-13 14:14:49 +00:00
wwwzbwcom
2c251ff33a
stream: make Readable.from performance better
...
PR-URL: https://github.com/nodejs/node/pull/37609
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-03-22 11:19:35 +02:00
Rich Trott
d10c59fc60
benchmark,test: remove output from readable-async-iterator benchmark
...
Extra output makes test-benchmark-streams fail. Change console.log() to
console.assert().
Fixes: https://github.com/nodejs/node/issues/34409
PR-URL: https://github.com/nodejs/node/pull/34411
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
2020-07-17 08:41:15 -07:00
Robert Nagy
08e8997d54
stream: simpler and faster Readable async iterator
...
Reimplement as an async generator instead of a custom
iterator class.
PR-URL: https://github.com/nodejs/node/pull/34035
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-07-17 09:06:27 +02:00
Robert Nagy
003fb53c9a
stream: avoid drain for sync streams
...
Previously a sync writable receiving chunks
larger than highwatermark would unecessarily
ping pong needDrain.
PR-URL: https://github.com/nodejs/node/pull/32887
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-04-25 18:45:50 +02:00
Daniele Belardi
4bf888d3d2
benchmark: use let instead of var
...
Use `let` in module, napi, net, os, path, process, querystring, streams
and string_decoder.
PR-URL: https://github.com/nodejs/node/pull/31592
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-13 21:41:33 +01:00
Brian White
b862a0c6d6
benchmark: check for and fix multiple end()
...
PR-URL: https://github.com/nodejs/node/pull/31624
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2020-02-08 21:36:31 -05:00
Robert Nagy
f68285b098
benchmark: include writev in benchmark
...
Currently we only consider write when benchmarking.
PR-URL: https://github.com/nodejs/node/pull/31066
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2019-12-25 23:45:49 +01:00
Robert Nagy
ea86f8c902
benchmark: update manywrites back pressure
...
Make manywrites benchmark a bit more realistic by
taking back pressure into account. Otherwise
memory usage would no correspond well with
real world usage.
PR-URL: https://github.com/nodejs/node/pull/30977
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-12-17 17:36:31 -08:00
Anna Henningsen
2205f85b2c
stream: improve performance for sync write finishes
...
Improve performance and reduce memory usage when a writable stream
is written to with the same callback (which is the most common case)
and when the write operation finishes synchronously (which is also
often the case).
confidence improvement accuracy (*) (**) (***)
streams/writable-manywrites.js sync='no' n=2000000 0.99 % ±3.20% ±4.28% ±5.61%
streams/writable-manywrites.js sync='yes' n=2000000 *** 710.69 % ±19.65% ±26.47% ±35.09%
Refs: https://github.com/nodejs/node/issues/18013
Refs: https://github.com/nodejs/node/issues/18367
PR-URL: https://github.com/nodejs/node/pull/30710
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-12-01 02:14:00 +01:00
Gus Caplan
8cae9b2ff8
tools: add no-duplicate-requires rule
...
PR-URL: https://github.com/nodejs/node/pull/21712
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Weijia Wang <starkwang@126.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jon Moss <me@jonathanmoss.me >
2018-07-12 16:11:11 -05:00
juggernaut451
b80da63b99
benchmark: changed millions and thousands to n
...
PR-URL: https://github.com/nodejs/node/pull/18917
Fixes: https://github.com/nodejs/node/issues/18778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Weijia Wang <starkwang@126.com >
Reviewed-By: Andreas Madsen <amwebdk@gmail.com >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com >
2018-04-10 00:22:33 +02:00
Brian White
b41ed29b80
stream: improve stream creation performance
...
PR-URL: https://github.com/nodejs/node/pull/19401
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-03-23 13:39:16 +01:00
Сковорода Никита Андреевич
8ed44ff1c4
test,benchmark: use new Buffer API where appropriate
...
For tests / benchmarks that are creating Buffer instances for
any reason other than to test Buffer constructor, use the new
Buffer.alloc/Buffer.from API instead of the deprecated API.
PR-URL: https://github.com/nodejs/node/pull/18980
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-03-04 12:50:15 +01:00
Mathias Buus
da97a47c44
benchmark: add stream.pipe benchmarks
...
PR-URL: https://github.com/nodejs/node/pull/18617
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-02-09 09:47:40 +01:00
Ruben Bridgewater
592454e703
benchmark: (streams) use destructuring
...
PR-URL: https://github.com/nodejs/node/pull/18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-01-23 01:29:20 +01:00
Ruben Bridgewater
e167ab71fb
benchmark: var to const
...
PR-URL: https://github.com/nodejs/node/pull/13757
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2017-09-19 21:14:38 -03:00
Brian White
e5dc934ef6
stream: improve Transform performance
...
PR-URL: https://github.com/nodejs/node/pull/13322
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-06-13 11:48:53 -07:00
Brian White
359ea2a0bd
stream: improve readable push performance
...
PR-URL: https://github.com/nodejs/node/pull/13113
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-05-23 20:50:22 +02:00
Bartosz Sosnowski
541119c6ee
benchmark: remove streams forced optimization
...
This removes all instances of %OptimizeFunctionOnNextCall from streams
benchmarks
PR-URL: https://github.com/nodejs/node/pull/9615
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2017-03-06 16:32:02 +01:00
Brian White
0a937280d8
stream: avoid additional validation for Buffers
...
These changes result in ~50% improvement in the included benchmark.
PR-URL: https://github.com/nodejs/node/pull/10580
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2017-01-05 02:58:05 -05:00
Brian White
686984696d
stream: improve Readable.read() performance
...
read() performance is improved most by switching from an array to
a linked list for storing buffered data. However, other changes that
also contribute include: making some hot functions inlinable, faster
read() argument checking, and misc code rearrangement to avoid
unnecessary code execution.
PR-URL: https://github.com/nodejs/node/pull/7077
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2016-06-14 15:15:34 -04:00