Skip to content

stream: optimize single-slot push queue drain - #63274

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
trivikr:stream-iter-push-queue-drain
May 15, 2026
Merged

stream: optimize single-slot push queue drain#63274
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
trivikr:stream-iter-push-queue-drain

Conversation

@trivikr

Copy link
Copy Markdown
Member

Optimize PushQueue.#drain() for the common single-slot case.

When only one slot is queued, return that slot directly instead of allocating a
new result array and copying every chunk into it. The existing flattening path is
kept for multi-slot drains.


Assisted-by: openai:gpt-5.5

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @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 13, 2026
@trivikr
trivikrforce-pushed the stream-iter-push-queue-drain branch from e0f819d to 31d0e90CompareMay 13, 2026 06:28
@trivikrtrivikr self-assigned this May 13, 2026
@trivikrtrivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 13, 2026
@codecov

codecovBot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.05%. Comparing base (2edd842) to head (4b44db4).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #63274 +/- ##
==========================================
+ Coverage 90.04% 90.05% +0.01% 
==========================================
Files 714 714 Lines 225338 225342 +4 Branches 42598 42608 +10 ==========================================
+ Hits 202897 202926 +29 + Misses 14236 14195 -41 - Partials 8205 8221 +16 
Files with missing linesCoverage Δ
lib/internal/streams/iter/push.js91.44% <100.00%> (+0.04%)⬆️

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

Avoid allocating a new result array when PushQueue drains a single
queued slot. Return that slot directly and keep the existing flattening
path for multiple queued slots.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@trivikr
trivikrforce-pushed the stream-iter-push-queue-drain branch from 31d0e90 to 4b44db4CompareMay 15, 2026 00:18
@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.

@trivikrtrivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 15, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikrtrivikr added the commit-queue Add this label to land a pull request using GitHub Actions. label May 15, 2026
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 15, 2026
@nodejs-github-bot
nodejs-github-bot merged commit be7ded1 into nodejs:mainMay 15, 2026
74 of 75 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in be7ded1

aduh95 pushed a commit that referenced this pull request May 19, 2026
Avoid allocating a new result array when PushQueue drains a single
queued slot. Return that slot directly and keep the existing flattening
path for multiple queued slots.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: #63274
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
Avoid allocating a new result array when PushQueue drains a single
queued slot. Return that slot directly and keep the existing flattening
path for multiple queued slots.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: #63274
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
@trivikr
trivikr deleted the stream-iter-push-queue-drain branch May 27, 2026 07:49
aduh95 pushed a commit to aduh95/node that referenced this pull request Jul 30, 2026
Avoid allocating a new result array when PushQueue drains a single
queued slot. Return that slot directly and keep the existing flattening
path for multiple queued slots.
Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
PR-URL: nodejs#63274
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.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