-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
build: add flag to enable pointer compression #30463
Conversation
Yeah, that’s expected. Enabling pointer compression changes the Node.js ABI, which is IIRC the reason why we haven’t done this so far. |
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.
This needs a good story for our addon ABI
Electron feels similarly - the memory savings are positive especially considering they're per-isolate but we're concerned about ABI compat of native modules |
@gabrielschulhof can you confirm n-api can handle this case? |
@addaleax my goal for this is to make it easier for folks to experiment with address compression. If you are ok, I'll add the option as "(experimental)" in the ./configure help. |
N-API is unaffected.
That would be good, but I’d prefer to explicitly call out that this mode does not currently support addons (at all)? |
Definite +1 on marking this experimental and documenting the impact on native addons. Assuming those changes, this LGTM |
Yeah iirc the plan was to consider having a build flag in V8 that ensures ABI stability regardless of whether pointer compression is enabled or not, by sacrificing some performance, since inline-implemented APIs would need to be replaced by non-inline versions. |
d10e3d6
to
4ac9eb8
Compare
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.
would be good to enable so we can at least start playing with it
4ac9eb8
to
7ec8e6d
Compare
I've removed the config from cc @targos |
I'm wondering whether there should be a warning printed at runtime when the node.js process starts. |
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 as an experimental build feature.
@nodejs/build @nodejs/testing I would need some help here, as tests that seems unrelated are failing, however this should not change the default config. |
@mcollina we currently rarely have green builds. There are lots of infrastructure failures and flaky tests. That's what seemed to have happened here as well. |
Landed in 086c7b4 |
The --experimental-enable-pointer-compression is experimental as it breaks ABI compatibility. PR-URL: nodejs#30463 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
The --experimental-enable-pointer-compression is experimental as it breaks ABI compatibility. PR-URL: #30463 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@targos any concerns on backporting this to diff --git a/common.gypi b/common.gypi
index 8c9076b735..856c6aa6ff 100644
--- a/common.gypi
+++ b/common.gypi
@@ -339,6 +339,12 @@
}],
],
}],
+ ['v8_enable_pointer_compression == 1', {
+ 'defines': ['V8_COMPRESS_POINTERS'],
+ }],
+ ['v8_enable_pointer_compression == 1 or v8_enable_31bit_smis_on_64bit_arch == 1', {
+ 'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'],
+ }],
['OS == "win"', {
'defines': [
'WIN32', The changes are non-intrusive, since it only impacts builds using |
where can i download a built version with |
@tuananh I believe you have to build it yourself as it is not in any of the shipping binaries. |
If this does get backported it will need to land with #33688 to fix building addons. |
Probably not worth it. We have pointer compressions builds for v14 now, and the pointer compression implementation on v12 has bugs as well as performance issues. |
`common.gypi` is used by `node-gyp` to compile addons. Default values must be provided for variables that may not exist on older versions of Node.js so that older versions of Node.js can be used to compile addons for later versions of Node.js. Add default values for `v8_enable_pointer_compression` and `v8_enable_31bit_smis_on_64bit_arch`. PR-URL: nodejs#33688 Refs: nodejs#30463 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Signed-off-by: Richard Lau <[email protected]>
`common.gypi` is used by `node-gyp` to compile addons. Default values must be provided for variables that may not exist on older versions of Node.js so that older versions of Node.js can be used to compile addons for later versions of Node.js. Add default values for `v8_enable_pointer_compression` and `v8_enable_31bit_smis_on_64bit_arch`. PR-URL: #33688 Refs: #30463 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Signed-off-by: Richard Lau <[email protected]>
`common.gypi` is used by `node-gyp` to compile addons. Default values must be provided for variables that may not exist on older versions of Node.js so that older versions of Node.js can be used to compile addons for later versions of Node.js. Add default values for `v8_enable_pointer_compression` and `v8_enable_31bit_smis_on_64bit_arch`. PR-URL: #33688 Refs: #30463 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Signed-off-by: Richard Lau <[email protected]>
`common.gypi` is used by `node-gyp` to compile addons. Default values must be provided for variables that may not exist on older versions of Node.js so that older versions of Node.js can be used to compile addons for later versions of Node.js. Add default values for `v8_enable_pointer_compression` and `v8_enable_31bit_smis_on_64bit_arch`. PR-URL: #33688 Refs: #30463 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Signed-off-by: Richard Lau <[email protected]>
Why wouldn’t this be useful now that we’re on node 18? |
This PR adds support for building node with pointer compression enabled. From some preliminary tests, enabling pointer compression shrinks memory usage by 40%.
See: #26756
Note that building with this flag makes some of our addon tests fail:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes