Skip to content

stream: limit iter from sync iterable batches - #63324

Merged
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
trivikr:stream-iter-from-iterable-batching
May 17, 2026
Merged

stream: limit iter from sync iterable batches#63324
nodejs-github-bot merged 2 commits into
nodejs:mainfrom
trivikr:stream-iter-from-iterable-batching

Conversation

@trivikr

Copy link
Copy Markdown
Member

Description

This updates stream/iter normalization to use bounded batches for sync
iterable input.

from() no longer batches sync iterables into one unbounded batch. Instead, it
flushes at FROM_BATCH_SIZE, improving first-batch latency and bounding peak
batch memory. fromSync() now also coalesces plain Uint8Array values from
sync iterables into bounded batches, allowing pipeToSync() to use writevSync
for those sources.

Benchmarks

Results showed statistically significant first-batch latency improvements for
from(syncIterable):

  • +3.19% for 256 chunks
  • +5.01% for 4096 chunks
  • +2.80% for 16384 chunks

The benchmark also showed a +6.91% writevSync improvement for the 256 chunk
case. The 4096 chunk writev result was not statistically significant.

 confidence improvement accuracy (*) (**) (***)streams/iter-from-batching.js n=100 chunkSize=16 chunks=256 method='from-sync-writev' *** 6.91 % ±1.99% ±2.65% ±3.46%streams/iter-from-batching.js n=100 chunkSize=16 chunks=4096 method='from-sync-writev' -2.63 % ±3.60% ±4.84% ±6.41%streams/iter-from-batching.js n=1000 chunkSize=16 chunks=16384 method='from-first-batch' *** 2.80 % ±1.39% ±1.86% ±2.44%streams/iter-from-batching.js n=1000 chunkSize=16 chunks=256 method='from-first-batch' *** 3.19 % ±1.27% ±1.68% ±2.19%streams/iter-from-batching.js n=1000 chunkSize=16 chunks=4096 method='from-first-batch' *** 5.01 % ±2.60% ±3.48% ±4.59%

Assisted-by: openai:gpt-5.5

trivikr added 2 commits May 14, 2026 23:11
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
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/streams

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels May 15, 2026
@trivikrtrivikr self-assigned this May 15, 2026
@codecov

codecovBot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.89474% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.02%. Comparing base (2edd842) to head (d08b083).
⚠️ Report is 17 commits behind head on main.

Files with missing linesPatch %Lines
lib/internal/streams/iter/from.js57.89%24 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #63324 +/- ##
==========================================
- Coverage 90.04% 90.02% -0.03% 
==========================================
Files 714 714 Lines 225338 225377 +39 Branches 42598 42610 +12 ==========================================
- Hits 202897 202886 -11 - Misses 14236 14267 +31 - Partials 8205 8224 +19 
Files with missing linesCoverage Δ
lib/internal/streams/iter/from.js86.05% <57.89%> (-2.77%)⬇️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikrtrivikr added request-ci Add this label to start a Jenkins CI on a PR. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels May 15, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 15, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikrtrivikr added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels May 16, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 17, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 265679b into nodejs:mainMay 17, 2026
111 of 116 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 265679b

aduh95 pushed a commit that referenced this pull request May 19, 2026
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: #63324
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
aduh95 pushed a commit that referenced this pull request May 19, 2026
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: #63324
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
@trivikr
trivikr deleted the stream-iter-from-iterable-batching branch May 27, 2026 07:49
aduh95 pushed a commit to aduh95/node that referenced this pull request Jul 30, 2026
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: nodejs#63324
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.needs-ciPRs that need a full CI run.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@trivikr@nodejs-github-bot@jasnell@Ethan-Arrowood