Skip to content

Commit 9a394ba

Browse files
trivikraduh95
authored andcommitted
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: #63314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 83054e8 commit 9a394ba

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

benchmark/streams/iter-throughput-broadcast.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ function benchIter(chunk, numConsumers, datasize, n, totalOps) {
128128
let remaining = datasize;
129129
while (remaining > 0) {
130130
const size = Math.min(remaining, chunk.length);
131-
remaining -= size;
132131
const buf = size === chunk.length ? chunk : chunk.subarray(0, size);
133-
writer.writeSync(buf);
132+
if (!writer.writeSync(buf)) {
133+
await writer.write(buf);
134+
}
135+
remaining -= size;
134136
}
135137
writer.endSync();
136138

0 commit comments

Comments
 (0)