GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zlib: skip the stream in sync convenience calls without options by anonrig · Pull Request #66864 · nodejs/node

Conversation

@anonrig

@anonrig anonrig commented Oct 19, 2026

Copy link
Copy Markdown
Member

zlib.inflateSync(buffer) and the other sync convenience methods build a Transform stream for every call, even though they only use its native handle. Without options, the stream is never exposed to the caller. They also allocate a fresh 16 KiB output chunk per call.

When no options are passed, this creates the native handle with the default settings directly and skips the stream. It also decompresses into a scratch buffer that's kept between calls and copies the result out. Calls with options, including info, keep the existing path.

Results and errors are unchanged. The new test compares every method against the same call with {} (which still goes through the stream): every input type, outputs that fit in one chunk, fill it exactly or span several, plus invalid and truncated input. It also checks that results never share memory, and that a sync call made from an async hook during another call still works. It passes on main too. One difference: a result that fits in one chunk is now its own allocation instead of a slice of a 16 KiB chunk, so small results don't keep that chunk alive anymore.

This is independent of #66854 and #66863. It only touches the sync path.

Benchmarks

benchmark/compare.js, default inputLen, n scaled down, against main. My machine was loaded (load average 15–30), so the intervals are wide:

benchmark run 1 (40 runs) run 2 (20 runs)
inflate.js method='inflateSync' +57.39% *** ±12.66% +71.62% *** ±27.39%
deflate.js method='deflateSync' +12.40% ** ±8.85% +12.49% ±17.03%

deflateSync gains less because most of its time goes to setting up and tearing down zlib's deflate state. The async deflate, inflate and createDeflate configurations, which this doesn't touch, came out within noise (−0.09% to +4.18%). I didn't get a clean pipe.js or creation.js run: pipe.js duration=1 failed on both main and this branch because the machine was too loaded to produce any output within a second.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@anonrig
zlib: skip the stream in sync convenience calls without options
af015be
`zlib.inflateSync(buffer)` and the other synchronous convenience
methods constructed a Transform stream for every call, even though
only its native handle is used and, without options, the stream is
never exposed. They also allocated a fresh output chunk for every
call.

When no options are passed, drive a native handle created with the
default settings directly, and decompress into a scratch buffer kept
between calls, copying the result out. Calls with options, including
`info`, keep the existing path. Results and errors are unchanged.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Grok
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Oct 19, 2026
@anonrig
anonrig requested review from H4ad and mcollina October 19, 2026 20:43
@codecov

codecov Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.50%. Comparing base (2052d0d) to head (af015be).
⚠️ Report is 139 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #66864    +/-   ##
========================================
  Coverage   90.50%   90.50%            
========================================
  Files         797      797            
  Lines      278195   278363   +168     
  Branches    53453    53509    +56     
========================================
+ Hits       251777   251931   +154     
- Misses      16795    16808    +13     
- Partials     9623     9624     +1     
Files with missing lines Coverage Δ
lib/zlib.js 98.32% <100.00%> (+0.20%) ⬆️

... and 32 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina approved these changes Oct 20, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@anonrig anonrig added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 20, 2026
@anonrig
anonrig requested a review from ronag October 20, 2026 15:15
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 20, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78518/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig anonrig added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 28, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 0160710 into nodejs:main Oct 28, 2026
81 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in 0160710

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 28, 2026
aduh95 pushed a commit that referenced this pull request Nov 11, 2026
@anonrig @aduh95
zlib: skip the stream in sync convenience calls without options
997d0d6
`zlib.inflateSync(buffer)` and the other synchronous convenience
methods constructed a Transform stream for every call, even though
only its native handle is used and, without options, the stream is
never exposed. They also allocated a fresh output chunk for every
call.

When no options are passed, drive a native handle created with the
default settings directly, and decompress into a scratch buffer kept
between calls, copying the result out. Calls with options, including
`info`, keep the existing path. Results and errors are unchanged.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Grok
PR-URL: #66864
Reviewed-By: Matteo Collina <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 11, 2026
2026-11-12, Version 27.0.0-alpha.0.1.0 (Alpha) #67415
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@anonrig @aduh95
zlib: skip the stream in sync convenience calls without options
2d64e56
`zlib.inflateSync(buffer)` and the other synchronous convenience
methods constructed a Transform stream for every call, even though
only its native handle is used and, without options, the stream is
never exposed. They also allocated a fresh output chunk for every
call.

When no options are passed, drive a native handle created with the
default settings directly, and decompress into a scratch buffer kept
between calls, copying the result out. Calls with options, including
`info`, keep the existing path. Results and errors are unchanged.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Grok
PR-URL: #66864
Reviewed-By: Matteo Collina <[email protected]>
@aduh95 aduh95 mentioned this pull request Nov 21, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@anonrig @gabylb
zlib: skip the stream in sync convenience calls without options
9046f88
`zlib.inflateSync(buffer)` and the other synchronous convenience
methods constructed a Transform stream for every call, even though
only its native handle is used and, without options, the stream is
never exposed. They also allocated a fresh output chunk for every
call.

When no options are passed, drive a native handle created with the
default settings directly, and decompress into a scratch buffer kept
between calls, copying the result out. Calls with options, including
`info`, keep the existing path. Results and errors are unchanged.

Signed-off-by: Yagiz Nizipli <[email protected]>
Assisted-by: Grok
PR-URL: nodejs#66864
Reviewed-By: Matteo Collina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@H4ad H4ad Awaiting requested review from H4ad
@ronag ronag Awaiting requested review from ronag

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@anonrig @nodejs-github-bot @mcollina
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.