-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
src: refactor compression allocation tracking, enable for zstd #61717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+184
−95
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
|
Review requested:
|
This aligns zstd streams with other compression libraries in this regard, and enables releasing memory early when the stream ends in JS instead of waiting for GC to clean up the wrapper object (which is a problem that is exacerbated in the zstd context because we do not track memory and report memory pressure to V8 yet).
This makes it a bit easier to separate concerns, and results in reduced code duplication when compiling since this code does not depend on template parameters.
This addresses a long-standing TODO comment, referencing the fact that these values are either known at compile time or can be inferred from the `this` value in the context class.
This is both valuable as a diagnostic tool and as a way to inform the JS runtime about external allocations. Currently, this is a feature only enabled in the statically linked builds of zstd, so with `--shared-zstd`, we fall back to the non-tracking variant.
c1e9728 to
5110ea4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61717 +/- ##
==========================================
- Coverage 89.73% 89.72% -0.01%
==========================================
Files 675 675
Lines 204502 204543 +41
Branches 39304 39307 +3
==========================================
+ Hits 183502 183535 +33
- Misses 13283 13284 +1
- Partials 7717 7724 +7
🚀 New features to boost your workflow:
|
benjamingr
approved these changes
Feb 7, 2026
Collaborator
anonrig
approved these changes
Feb 9, 2026
Contributor
Failed to start CI⚠ Commits were pushed since the last approving review: ⚠ - src: release memory for zstd contexts in `Close()` ⚠ - src: extract zlib allocation tracking into its own class ⚠ - src: do not store compression methods on Brotli classes ⚠ - src: track allocations made by zstd streams ⚠ - fixup! src: track allocations made by zstd streams ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/21819727735 |
Member
Author
|
@anonrig CI did catch a typo here so I fixed – feel free to re-review & kick off CI again 🙂 |
RafaelGSS
approved these changes
Feb 9, 2026
Collaborator
Collaborator
Collaborator
Collaborator
Collaborator
|
Landed in 5dfb1a2...8ba4d72 |
nodejs-github-bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
This aligns zstd streams with other compression libraries in this regard, and enables releasing memory early when the stream ends in JS instead of waiting for GC to clean up the wrapper object (which is a problem that is exacerbated in the zstd context because we do not track memory and report memory pressure to V8 yet). PR-URL: #61717 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
nodejs-github-bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
This makes it a bit easier to separate concerns, and results in reduced code duplication when compiling since this code does not depend on template parameters. PR-URL: #61717 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
nodejs-github-bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
This addresses a long-standing TODO comment, referencing the fact that these values are either known at compile time or can be inferred from the `this` value in the context class. PR-URL: #61717 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
nodejs-github-bot
pushed a commit
that referenced
this pull request
Feb 9, 2026
This is both valuable as a diagnostic tool and as a way to inform the JS runtime about external allocations. Currently, this is a feature only enabled in the statically linked builds of zstd, so with `--shared-zstd`, we fall back to the non-tracking variant. PR-URL: #61717 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
build
Issues and PRs related to build files or the CI.
c++
Issues and PRs that require attention from people who are familiar with C++.
commit-queue-rebase
Add this label to allow the Commit Queue to land a PR in several commits.
needs-ci
PRs that need a full CI run.
review wanted
PRs that need reviews.
zlib
Issues and PRs related to the zlib subsystem.
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.
src: release memory for zstd contexts in
Close()This aligns zstd streams with other compression libraries in this regard,
and enables releasing memory early when the stream ends in JS instead of
waiting for GC to clean up the wrapper object (which is a problem that
is exacerbated in the zstd context because we do not track memory
and report memory pressure to V8 yet).
src: extract zlib allocation tracking into its own class
This makes it a bit easier to separate concerns, and results in
reduced code duplication when compiling since this code does not
depend on template parameters.
src: do not store compression methods on Brotli classes
This addresses a long-standing TODO comment, referencing the fact
that these values are either known at compile time or can be
inferred from the
thisvalue in the context class.src: track allocations made by zstd streams
This is both valuable as a diagnostic tool and as a way to inform
the JS runtime about external allocations.
Currently, this is a feature only enabled in the statically linked
builds of zstd, so with
--shared-zstd, we fall back to thenon-tracking variant.