src: refactor compression allocation tracking, enable for zstd#61717
Open
addaleax wants to merge 4 commits intonodejs:mainfrom
Open
src: refactor compression allocation tracking, enable for zstd#61717addaleax wants to merge 4 commits intonodejs:mainfrom
addaleax wants to merge 4 commits intonodejs:mainfrom
Conversation
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 204516 +14
Branches 39304 39303 -1
==========================================
+ Hits 183502 183510 +8
- Misses 13283 13292 +9
+ Partials 7717 7714 -3
🚀 New features to boost your workflow:
|
benjamingr
approved these changes
Feb 7, 2026
Collaborator
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.