0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00

v8: enable maglev on supported architectures

Enable V8's new maglev compiler by default on supported architectures.
This brings modest performance improvements for short-lived workloads
like CLI programs (see the linked issue) and brings Node.js's
configuration slightly closer to Google Chrome's.

I marked this change as semver-major because Maglev can theoretically
cause performance regressions, although I haven't seen an example of
that in the (somewhat limited) benchmarking I've done.

**Notable Change Summary:** V8's Maglev Compiler is now enabled by
default on supported architectures (https://v8.dev/blog/maglev). Maglev
improves CPU performance for short-lived CLI programs by around 8%.

Fixes: https://github.com/nodejs/node/issues/50690
PR-URL: https://github.com/nodejs/node/pull/51360
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Keyhan Vakil 2024-01-07 16:29:10 -08:00 committed by GitHub
parent 09a506fe7d
commit 1a5acd0638
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,7 @@ valid_mips_fpu = ('fp32', 'fp64', 'fpxx')
valid_mips_float_abi = ('soft', 'hard')
valid_intl_modes = ('none', 'small-icu', 'full-icu', 'system-icu')
icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8'))
maglev_enabled_architectures = ('x64', 'arm', 'arm64')
shareable_builtins = {'cjs_module_lexer/lexer': 'deps/cjs-module-lexer/lexer.js',
'cjs_module_lexer/dist/lexer': 'deps/cjs-module-lexer/dist/lexer.js',
@ -812,11 +813,13 @@ parser.add_argument('--v8-enable-hugepage',
help='Enable V8 transparent hugepage support. This feature is only '+
'available on Linux platform.')
parser.add_argument('--v8-enable-maglev',
maglev_enabled_by_default_help = f"(Maglev is enabled by default on {','.join(maglev_enabled_architectures)})"
parser.add_argument('--v8-disable-maglev',
action='store_true',
dest='v8_enable_maglev',
dest='v8_disable_maglev',
default=None,
help='Enable V8 Maglev compiler. Not available on all platforms.')
help=f"Disable V8's Maglev compiler. {maglev_enabled_by_default_help}")
parser.add_argument('--v8-enable-short-builtin-calls',
action='store_true',
@ -1498,7 +1501,8 @@ def configure_v8(o):
o['variables']['v8_random_seed'] = 0 # Use a random seed for hash tables.
o['variables']['v8_promise_internal_field_count'] = 1 # Add internal field to promises for async hooks.
o['variables']['v8_use_siphash'] = 0 if options.without_siphash else 1
o['variables']['v8_enable_maglev'] = 1 if options.v8_enable_maglev else 0
o['variables']['v8_enable_maglev'] = B(not options.v8_disable_maglev and
o['variables']['target_arch'] in maglev_enabled_architectures)
o['variables']['v8_enable_pointer_compression'] = 1 if options.enable_pointer_compression else 0
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
o['variables']['v8_enable_shared_ro_heap'] = 0 if options.enable_pointer_compression or options.disable_shared_ro_heap else 1