From 125c19da431bdbb1cd91e2acbf4046edfefb04cf Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 12 Jul 2026 17:22:04 -0700 Subject: [PATCH] stream, quic: update iterable streams backpressure Signed-off-by: James M Snell Assisted-by: Opencode/Opus PR-URL: https://github.com/nodejs/node/pull/64464 Reviewed-By: Tim Perry Reviewed-By: Trivikram Kamat Reviewed-By: Ethan Arrowood --- benchmark/streams/iter-throughput-share.js | 4 +- doc/api/quic.md | 9 ++- doc/api/stream_iter.md | 6 +- lib/internal/quic/quic.js | 50 ++++++------ lib/internal/quic/state.js | 18 ++--- lib/internal/streams/iter/broadcast.js | 3 +- lib/internal/streams/iter/push.js | 19 ++++- lib/internal/streams/iter/share.js | 5 +- lib/internal/streams/iter/utils.js | 13 --- src/quic/streams.cc | 16 ++-- .../test-quic-flow-control-params.mjs | 2 +- test/parallel/test-quic-flow-control-uni.mjs | 2 +- .../parallel/test-quic-stream-bidi-writer.mjs | 6 +- ...quic-stream-destroy-emits-stop-sending.mjs | 20 ++--- .../test-quic-stream-uni-server-initiated.mjs | 2 +- test/parallel/test-quic-stream-writer-api.mjs | 16 ++-- .../test-quic-stream-writer-dispose.mjs | 6 +- .../test-quic-writer-backpressure.mjs | 20 ++--- .../test-quic-writer-write-rejects.mjs | 12 +-- ...test-stream-iter-broadcast-backpressure.js | 44 ++++++----- .../test-stream-iter-broadcast-basic.js | 10 +-- .../test-stream-iter-broadcast-coverage.js | 4 +- .../test-stream-iter-pipeto-writev.js | 35 ++++---- .../test-stream-iter-push-backpressure.js | 79 +++++++++---------- test/parallel/test-stream-iter-push-basic.js | 11 ++- test/parallel/test-stream-iter-push-writer.js | 48 ++++++----- test/parallel/test-stream-iter-share-from.js | 53 +++++++------ test/parallel/test-stream-iter-validation.js | 59 +++++++------- 28 files changed, 292 insertions(+), 280 deletions(-) diff --git a/benchmark/streams/iter-throughput-share.js b/benchmark/streams/iter-throughput-share.js index a0383172c04..c17444d8103 100644 --- a/benchmark/streams/iter-throughput-share.js +++ b/benchmark/streams/iter-throughput-share.js @@ -5,7 +5,7 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { consumers: [2, 8, 32], batches: [1e4], - backpressure: ['block'], + backpressure: ['unbounded'], n: [5], }, { flags: ['--experimental-stream-iter'], @@ -24,7 +24,7 @@ async function main({ consumers, batches, backpressure, n }) { bench.start(); for (let i = 0; i < n; i++) { - const shared = share(source(), { highWaterMark: 64, backpressure }); + const shared = share(source(), { budget: 65536, backpressure }); const readers = Array.from({ length: consumers }, () => array(shared.pull())); await Promise.all(readers); } diff --git a/doc/api/quic.md b/doc/api/quic.md index c366d1d7292..88a291fc6d5 100644 --- a/doc/api/quic.md +++ b/doc/api/quic.md @@ -1276,7 +1276,7 @@ added: v23.8.0 interleaved with data from other streams of the same priority level. When `false`, the stream should be completed before same-priority peers. **Default:** `false`. - * `highWaterMark` {number} The maximum number of bytes that the writer + * `budget` {number} The maximum number of bytes that the writer will buffer before `writeSync()` returns `false`. When the buffered data exceeds this limit, the caller should wait for drain before writing more. **Default:** `65536` (64 KB). @@ -1317,7 +1317,7 @@ added: v23.8.0 interleaved with data from other streams of the same priority level. When `false`, the stream should be completed before same-priority peers. **Default:** `false`. - * `highWaterMark` {number} The maximum number of bytes that the writer + * `budget` {number} The maximum number of bytes that the writer will buffer before `writeSync()` returns `false`. When the buffered data exceeds this limit, the caller should wait for drain before writing more. **Default:** `65536` (64 KB). @@ -1924,7 +1924,7 @@ added: v23.8.0 The directionality of the stream, or `null` if the stream has been destroyed or is still pending. Read only. -### `stream.highWaterMark` +### `stream.budget`