Skip to content

stream: speed up reads and iteration over default WHATWG streams - #64320

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:webstream-iterator-perf-round6
Jul 11, 2026
Merged

stream: speed up reads and iteration over default WHATWG streams#64320
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:webstream-iterator-perf-round6

Conversation

@mcollina

@mcollinamcollina commented Jul 6, 2026

Copy link
Copy Markdown
Member

Skip the size algorithm call when it is the default one, and stop re-running the full ShouldCallPull predicate at per-chunk call sites where its inputs are already established.

readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. web streams labels Jul 6, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina
mcollinaforce-pushed the webstream-iterator-perf-round6 branch from 31fb1fe to e16a18dCompareJuly 7, 2026 17:53
@codecov

codecovBot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.25%. Comparing base (7036199) to head (0ff7249).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #64320 +/- ##
=======================================
Coverage 90.25% 90.25% =======================================
Files 741 741 Lines 241207 241249 +42 Branches 45424 45444 +20 =======================================
+ Hits 217696 217734 +38 - Misses 15087 15089 +2 - Partials 8424 8426 +2 
Files with missing linesCoverage Δ
lib/internal/webstreams/readablestream.js98.18% <100.00%> (+0.02%)⬆️

... and 26 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.

@mertcanaltinmertcanaltin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 8, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 8, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Skip the size algorithm call and its result validation when the size
algorithm is the default one, and stop re-running the full
ShouldCallPull predicate at per-chunk call sites where its inputs are
already established.
readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollinaforce-pushed the webstream-iterator-perf-round6 branch from e16a18d to 0ff7249CompareJuly 9, 2026 09:15
@aduh95aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 9, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 9, 2026
@nodejs-github-bot

nodejs-github-bot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@gurgundaygurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina

Copy link
Copy Markdown
MemberAuthor

Results confirmed on Github Action bench:

Benchmark results:

 confidence improvement accuracy (*) (**) (***)
webstreams/creation.js kind='ReadableStream.tee' n=50000 -1.28 % ±10.30% ±13.58% ±17.42%
webstreams/creation.js kind='ReadableStream' n=50000 0.63 % ±11.33% ±14.93% ±19.16%
webstreams/creation.js kind='ReadableStreamBYOBReader' n=50000 -0.98 % ±8.08% ±10.65% ±13.66%
webstreams/creation.js kind='ReadableStreamDefaultReader' n=50000 2.51 % ±9.10% ±11.99% ±15.38%
webstreams/creation.js kind='TransformStream' n=50000 -0.30 % ±10.43% ±13.75% ±17.64%
webstreams/creation.js kind='WritableStream' n=50000 -0.26 % ±11.46% ±15.11% ±19.39%
webstreams/js_transfer.js n=10000 payload='ReadableStream' -0.47 % ±14.78% ±19.48% ±25.00%
webstreams/js_transfer.js n=10000 payload='TransformStream' -0.87 % ±13.60% ±17.92% ±23.00%
webstreams/js_transfer.js n=10000 payload='WritableStream' -1.65 % ±14.04% ±18.51% ±23.75%
webstreams/pipe-to.js highWaterMarkW=1024 highWaterMarkR=1024 n=500000 3.87 % ±9.25% ±12.19% ±15.65%
webstreams/pipe-to.js highWaterMarkW=1024 highWaterMarkR=2048 n=500000 3.26 % ±9.22% ±12.15% ±15.59%
webstreams/pipe-to.js highWaterMarkW=1024 highWaterMarkR=4096 n=500000 2.47 % ±9.20% ±12.12% ±15.56%
webstreams/pipe-to.js highWaterMarkW=1024 highWaterMarkR=512 n=500000 4.39 % ±9.46% ±12.47% ±16.00%
webstreams/pipe-to.js highWaterMarkW=2048 highWaterMarkR=1024 n=500000 3.31 % ±9.23% ±12.17% ±15.62%
webstreams/pipe-to.js highWaterMarkW=2048 highWaterMarkR=2048 n=500000 2.08 % ±9.14% ±12.05% ±15.46%
webstreams/pipe-to.js highWaterMarkW=2048 highWaterMarkR=4096 n=500000 1.99 % ±9.40% ±12.38% ±15.89%
webstreams/pipe-to.js highWaterMarkW=2048 highWaterMarkR=512 n=500000 4.86 % ±9.35% ±12.32% ±15.81%
webstreams/pipe-to.js highWaterMarkW=4096 highWaterMarkR=1024 n=500000 2.29 % ±9.28% ±12.23% ±15.69%
webstreams/pipe-to.js highWaterMarkW=4096 highWaterMarkR=2048 n=500000 5.29 % ±9.43% ±12.43% ±15.95%
webstreams/pipe-to.js highWaterMarkW=4096 highWaterMarkR=4096 n=500000 1.22 % ±9.32% ±12.29% ±15.77%
webstreams/pipe-to.js highWaterMarkW=4096 highWaterMarkR=512 n=500000 3.66 % ±9.33% ±12.30% ±15.78%
webstreams/pipe-to.js highWaterMarkW=512 highWaterMarkR=1024 n=500000 3.05 % ±9.22% ±12.16% ±15.60%
webstreams/pipe-to.js highWaterMarkW=512 highWaterMarkR=2048 n=500000 1.27 % ±9.12% ±12.02% ±15.42%
webstreams/pipe-to.js highWaterMarkW=512 highWaterMarkR=4096 n=500000 3.18 % ±9.24% ±12.18% ±15.62%
webstreams/pipe-to.js highWaterMarkW=512 highWaterMarkR=512 n=500000 3.75 % ±9.41% ±12.40% ±15.92%
webstreams/readable-async-iterator.js type='bytes' n=100000 5.35 % ±10.80% ±14.24% ±18.28%
webstreams/readable-async-iterator.js type='normal' n=100000 *** 18.67 % ±9.03% ±11.90% ±15.27%
webstreams/readable-read-buffered.js bufferSize=1 n=100000 ** 13.13 % ±9.16% ±12.08% ±15.50%
webstreams/readable-read-buffered.js bufferSize=10 n=100000 *** 20.16 % ±8.85% ±11.67% ±14.98%
webstreams/readable-read-buffered.js bufferSize=100 n=100000 *** 25.05 % ±9.02% ±11.89% ±15.26%
webstreams/readable-read-buffered.js bufferSize=1000 n=100000 *** 22.69 % ±9.19% ±12.11% ±15.55%
webstreams/readable-read.js type='byob' n=100000 -0.39 % ±11.56% ±15.24% ±19.56%
webstreams/readable-read.js type='normal' n=100000 -0.10 % ±9.07% ±11.95% ±15.34%

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 11, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 11, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 9f1ae22 into nodejs:mainJul 11, 2026
75 of 76 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 9f1ae22

aduh95 pushed a commit that referenced this pull request Jul 21, 2026
Skip the size algorithm call and its result validation when the size
algorithm is the default one, and stop re-running the full
ShouldCallPull predicate at per-chunk call sites where its inputs are
already established.
readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
aduh95 pushed a commit that referenced this pull request Jul 21, 2026
Skip the size algorithm call and its result validation when the size
algorithm is the default one, and stop re-running the full
ShouldCallPull predicate at per-chunk call sites where its inputs are
already established.
readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
RafaelGSS pushed a commit that referenced this pull request Jul 29, 2026
Skip the size algorithm call and its result validation when the size
algorithm is the default one, and stop re-running the full
ShouldCallPull predicate at per-chunk call sites where its inputs are
already established.
readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
aduh95 pushed a commit that referenced this pull request Aug 6, 2026
Skip the size algorithm call and its result validation when the size
algorithm is the default one, and stop re-running the full
ShouldCallPull predicate at per-chunk call sites where its inputs are
already established.
readable-async-iterator type=normal: +16.6% (***)
readable-read-buffered: +13.9% to +27.5% (**/***)
pipe-to: +3.7% to +6.0% (15/16 configs significant)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #64320
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
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.needs-ciPRs that need a full CI run.web streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@mcollina@nodejs-github-bot@ShogunPanda@jasnell@aduh95@mertcanaltin@gurgunday