Skip to content

Commit 1ddc438

Browse files
joyeecheungdanielleadams
authored andcommitted
build: disable v8 snapshot compression by default
In the upstream, V8 also disables snapshot compression on the desktop by default because the size reduction is not worth the performance hit. https://chromium-review.googlesource.com/c/v8/v8/+/3275554 Locally the binary size of Node.js is increased by ~2.7MB (+3.2%) with a significant speedup in startup after snapshot compression is disabled on macOS. Also adds a --v8-enable-snapshot-compression to configure.py for users who prefer a size reduction over speedup in startup. Ideally we should implement our own compression for the source code + the code cache + the snapshot instead of relying on V8's builtin compression for just the snapshot. PR-URL: #45716 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
1 parent 3cee3ca commit 1ddc438

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

configure.py

+8
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,12 @@
834834
help='Enable V8 short builtin calls support. This feature is enabled '+
835835
'on x86_64 platform by default.')
836836

837+
parser.add_argument('--v8-enable-snapshot-compression',
838+
action='store_true',
839+
dest='v8_enable_snapshot_compression',
840+
default=None,
841+
help='Enable the built-in snapshot compression in V8.')
842+
837843
parser.add_argument('--node-builtin-modules-path',
838844
action='store',
839845
dest='node_builtin_modules_path',
@@ -1535,6 +1541,8 @@ def configure_v8(o):
15351541
o['variables']['v8_enable_hugepage'] = 1 if options.v8_enable_hugepage else 0
15361542
if options.v8_enable_short_builtin_calls or o['variables']['target_arch'] == 'x64':
15371543
o['variables']['v8_enable_short_builtin_calls'] = 1
1544+
if options.v8_enable_snapshot_compression:
1545+
o['variables']['v8_enable_snapshot_compression'] = 1
15381546
if options.v8_enable_object_print and options.v8_disable_object_print:
15391547
raise Exception(
15401548
'Only one of the --v8-enable-object-print or --v8-disable-object-print options '

tools/v8_gypfiles/features.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
'v8_enable_regexp_interpreter_threaded_dispatch%': 1,
212212

213213
# Disable all snapshot compression.
214-
'v8_enable_snapshot_compression%': 1,
214+
'v8_enable_snapshot_compression%': 0,
215215

216216
# Enable control-flow integrity features, such as pointer authentication
217217
# for ARM64.

0 commit comments

Comments
 (0)