Files
node/test/parallel
Matteo Collina 4551732bf1 stream: speed up async iteration of Readable
Replace the async generator backing Symbol.asyncIterator with a
hand-rolled iterator. The generator machinery costs several extra
promise allocations and microtask hops per chunk: yield awaits the
yielded value and resolves the pending request through separate
promises. Buffered chunks are now delivered as an already-resolved
promise, one microtask sooner than before.

Thenable chunks are still awaited before delivery, requests received
while a next() is outstanding are queued, and return()/throw() before
the first next() complete the iterator without touching the stream.

The earlier delivery is observable by code racing an abort against
the first chunk. The flatMap AbortSignal test relied on such a race;
it is reworked to abort deterministically while two mappers are in
flight, asserting the concurrency limit, in-flight cancellation and
rejection, without depending on delivery timing or timers.

streams/readable-async-iterator.js sync='yes': +32.59% (***)
streams/readable-async-iterator.js sync='no': +9.84% (***)

Assisted-by: Claude Fable 5
Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64447
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-08-14 22:44:35 +00:00
..
2026-08-01 14:48:00 +02:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-07-18 12:59:37 -07:00
2026-08-05 22:50:13 -07:00