Yagiz Nizipli
1912893c29
stream: use ring buffer for WHATWG stream queues
...
The [[queue]] backing every default readable/writable controller was a
plain array of { value, size } wrappers consumed with
ArrayPrototypeShift, so each buffered chunk allocated a wrapper object
and each dequeue moved (or forced the engine to re-linearize) the
remaining elements; the byte controller queue paid the same shift cost
for its chunk descriptor records.
Replace the array with a power-of-two ring buffer. Default controller
queues store each entry as (value, size) in two consecutive slots, so
the per-chunk wrapper allocation disappears; the byte controller keeps
its descriptor records (they are mutated in place at the head) in
single slots. Controllers start from (and are reset to) a shared
immutable empty queue, so constructing a stream allocates no queue
storage until a chunk is actually buffered. Enqueues measured by the
internal default size algorithm (never observable by user code, always
returns 1, cannot throw) skip the algorithm call and its try/catch
entirely.
The layout mirrors what Bun/WebKit use for the same spec structure:
[[queue]] as a ring-buffer deque (WTF::Deque in Bun's
src/jsc/bindings/webcore/streams/StreamQueue.h), the pure-JS ring
buffer in Bun's src/js/internal/fifo.ts, and the trivial-size-algorithm
bypass in
src/jsc/bindings/webcore/streams/JSReadableStreamDefaultController.cpp.
benchmark/compare.js against the unmodified baseline (30-run capture
plus an independent 15-run repeat, Welch t-test, all p < 1e-5):
webstreams/pipe-to.js +12-17% across all sixteen high-water-mark
configurations, readable-read-buffered +20% (bufferSize=1) to +49%
(bufferSize=1000), readable-async-iterator +21%. No stable significant
regression across the rest of the webstreams suite: the creation.js and
readable-read.js deltas seen in the full-suite capture disappear in
isolated 60-run rechecks.
Refs: https://github.com/oven-sh/bun/blob/main/src/js/internal/fifo.ts
Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com >
Assisted-by: Grok (Grok Build)
PR-URL: https://github.com/nodejs/node/pull/64312
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-07-08 15:05:45 +00:00
..
2026-06-20 15:45:37 +00:00
2026-05-28 15:44:05 +00:00
2026-07-02 04:52:17 +00:00
2026-06-12 16:02:01 +00:00
2026-06-05 11:41:01 +02:00
2026-06-12 23:26:19 +00:00
2026-06-12 23:26:19 +00:00
2026-07-06 09:12:59 +02:00
2026-06-18 18:14:46 +00:00
2026-06-23 17:10:12 +00:00
2026-06-23 17:10:12 +00:00
2026-06-23 17:10:12 +00:00
2026-06-21 11:18:48 +00:00
2026-06-21 11:18:48 +00:00
2026-06-15 21:22:58 +00:00
2026-06-19 18:03:51 +02:00
2026-06-17 17:18:40 +00:00
2026-06-17 17:18:40 +00:00
2026-06-15 21:22:58 +00:00
2026-06-17 09:11:58 +00:00
2026-06-14 15:22:50 +00:00
2026-06-21 11:18:48 +00:00
2026-06-19 07:50:57 +00:00
2026-06-17 17:18:40 +00:00
2026-06-20 18:42:04 +02:00
2026-05-31 14:25:27 +00:00
2026-06-21 11:18:48 +00:00
2026-06-21 11:18:48 +00:00
2026-05-26 11:25:44 +02:00
2026-05-26 11:25:44 +02:00
2026-06-21 11:18:48 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-05-26 10:20:15 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-13 20:50:15 +00:00
2026-06-13 20:50:15 +00:00
2026-06-13 20:50:15 +00:00
2026-06-13 20:50:15 +00:00
2026-06-13 20:50:15 +00:00
2026-06-13 20:50:15 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-18 04:24:28 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-01 20:36:47 +00:00
2026-06-19 09:26:48 +00:00
2026-06-15 19:01:19 +00:00
2026-06-15 19:01:36 +00:00
2026-06-17 19:09:05 +00:00
2026-06-30 13:07:49 +00:00
2026-06-30 13:07:49 +00:00
2026-06-26 10:02:49 +00:00
2026-06-26 10:02:49 +00:00
2026-06-18 06:29:24 +02:00
2026-05-31 14:25:28 +00:00
2026-06-21 19:42:03 +00:00
2026-06-21 19:42:03 +00:00
2026-06-21 19:42:03 +00:00
2026-06-21 19:42:03 +00:00
2026-06-10 10:56:56 +00:00
2026-05-26 17:19:42 +00:00
2026-05-28 15:44:05 +00:00
2026-06-20 16:12:16 +09:00
2026-06-16 02:30:51 +00:00
2026-05-31 14:25:29 +00:00
2026-06-13 10:08:05 +00:00
2026-06-13 10:08:05 +00:00
2026-05-27 21:30:47 +02:00
2026-06-21 01:31:38 +00:00
2026-06-03 05:34:23 +00:00
2026-06-09 04:53:43 +00:00
2026-06-01 10:59:19 +00:00
2026-05-28 06:25:13 +00:00
2026-06-01 10:59:19 +00:00
2026-05-28 06:25:13 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-07-07 14:24:14 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-08 11:53:02 +00:00
2026-06-01 10:59:19 +00:00
2026-06-18 06:29:23 +02:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-01 10:59:19 +00:00
2026-06-18 06:29:24 +02:00
2026-06-20 14:58:11 +00:00
2026-06-20 14:58:11 +00:00
2026-07-03 12:34:27 +00:00
2026-05-30 08:10:58 +00:00
2026-05-30 08:10:58 +00:00
2026-07-02 15:28:39 +00:00
2026-06-05 09:27:53 +00:00
2026-07-08 00:59:28 +00:00
2026-06-18 06:29:24 +02:00
2026-06-20 04:04:20 +00:00
2026-06-04 12:25:20 +00:00
2026-07-06 12:40:25 +00:00
2026-06-02 14:25:47 +02:00
2026-07-06 15:15:59 +00:00
2026-06-20 14:40:48 -07:00
2026-06-18 06:29:24 +02:00
2026-06-13 23:12:25 +00:00
2026-05-31 14:25:30 +00:00
2026-05-28 06:25:00 +00:00
2026-07-04 08:56:09 +00:00
2026-06-12 16:02:01 +00:00
2026-06-30 14:29:38 +01:00
2026-06-24 23:50:06 +00:00
2026-06-23 15:24:08 +00:00
2026-06-23 15:24:08 +00:00
2026-07-02 16:57:42 +00:00
2026-07-02 15:28:24 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-05-26 13:40:14 +00:00
2026-06-18 06:29:24 +02:00
2026-06-18 06:29:23 +02:00
2026-06-18 06:29:24 +02:00
2026-07-07 15:29:10 +00:00
2026-06-30 21:38:02 +00:00
2026-05-28 20:02:05 +00:00
2026-05-31 12:48:59 -07:00
2026-06-10 13:33:00 +00:00
2026-06-14 13:06:39 +00:00
2026-05-31 12:48:59 -07:00
2026-05-28 20:02:05 +00:00
2026-07-07 08:19:40 +00:00
2026-07-07 08:19:40 +00:00
2026-06-20 20:11:47 +00:00
2026-07-07 02:58:16 +00:00
2026-05-28 20:02:05 +00:00
2026-05-28 20:02:05 +00:00
2026-06-20 10:30:41 +00:00
2026-06-20 20:11:58 +00:00
2026-07-07 13:30:37 +00:00
2026-05-28 20:02:05 +00:00
2026-07-06 12:40:45 +00:00
2026-05-28 15:44:05 +00:00
2026-06-21 19:42:03 +00:00
2026-06-12 16:02:01 +00:00
2026-05-28 07:47:24 +00:00
2026-06-23 22:06:23 +00:00
2026-05-26 13:41:29 +00:00
2026-07-07 15:29:21 +00:00
2026-06-22 15:42:03 +00:00
2026-06-23 15:24:49 +00:00
2026-06-13 09:02:10 +00:00
2026-07-07 15:29:21 +00:00
2026-06-09 23:02:56 +09:00
2026-06-10 11:36:03 +09:00
2026-06-16 16:29:30 +00:00
2026-05-28 04:56:05 +00:00
2026-07-07 12:40:43 +00:00
2026-06-23 15:24:34 +00:00
2026-06-09 04:53:54 +00:00
2026-06-22 07:47:25 +00:00
2026-06-30 06:25:00 +00:00
2026-07-04 22:12:51 +00:00
2026-07-04 19:47:30 +00:00
2026-07-08 07:06:40 +00:00
2026-06-22 07:47:40 +00:00
2026-06-08 22:45:07 +00:00
2026-06-15 03:49:40 +00:00
2026-06-07 19:16:05 +00:00
2026-06-17 16:08:46 +00:00
2026-06-01 23:18:12 +00:00
2026-06-22 07:47:25 +00:00
2026-06-30 06:25:00 +00:00
2026-06-17 16:08:46 +00:00
2026-07-06 15:15:59 +00:00
2026-06-20 09:35:34 +00:00
2026-06-09 14:21:21 +00:00
2026-06-21 19:42:03 +00:00
2026-06-19 16:07:24 +02:00
2026-07-08 09:57:03 +00:00
2026-07-01 06:40:40 +00:00
2026-06-19 18:03:51 +02:00
2026-06-19 18:03:51 +02:00
2026-06-19 18:03:51 +02:00
2026-07-03 12:34:27 +00:00
2026-06-18 00:00:51 +00:00
2026-06-18 06:29:24 +02:00
2026-06-18 06:29:23 +02:00
2026-06-02 12:59:55 +00:00
2026-06-14 07:01:35 +00:00
2026-06-14 07:01:35 +00:00
2026-06-23 19:21:47 +00:00
2026-05-29 17:57:34 +00:00
2026-07-04 07:58:04 +00:00
2026-07-04 07:58:04 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-07-04 07:58:04 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-06-27 06:07:44 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-07-02 15:28:55 +00:00
2026-07-07 01:09:03 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-05-29 17:57:34 +00:00
2026-06-30 10:08:40 +00:00
2026-06-27 06:07:44 +00:00
2026-07-06 14:06:19 +00:00
2026-05-29 17:57:34 +00:00
2026-07-07 17:59:01 +00:00
2026-05-27 14:42:58 +00:00
2026-06-29 20:25:55 +00:00
2026-06-11 15:49:20 +00:00
2026-06-21 08:47:04 +00:00
2026-06-04 23:20:48 +00:00
2026-05-26 20:36:56 +00:00
2026-06-17 17:18:40 +00:00
2026-06-20 18:42:04 +02:00
2026-06-20 18:42:04 +02:00
2026-06-20 18:42:04 +02:00
2026-06-20 18:42:04 +02:00
2026-06-20 18:42:04 +02:00
2026-06-09 19:48:16 +00:00
2026-06-20 18:42:04 +02:00
2026-05-25 16:36:32 +00:00
2026-06-16 11:34:37 +00:00
2026-06-23 20:44:57 +02:00
2026-06-20 18:42:04 +02:00
2026-06-20 18:42:04 +02:00
2026-06-17 10:53:43 +00:00
2026-06-20 18:42:04 +02:00
2026-05-27 08:13:58 +00:00
2026-07-08 15:05:45 +00:00
2026-07-05 08:04:44 +00:00
2026-06-09 07:40:15 +00:00
2026-07-07 11:53:27 +00:00
2026-06-06 04:45:58 +00:00
2026-07-06 15:15:46 +00:00
2026-05-31 14:25:31 +00:00
2026-06-27 11:22:32 +00:00
2026-06-27 11:22:31 +00:00