From 02ea3b0dc43522e72c0d129658f93dceadb09fa6 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Fri, 13 Dec 2019 11:59:37 -0800 Subject: [PATCH 1/9] src: make --use-largepages a runtime option Moves the option that instructs Node.js to-remap its static code to large pages from a configure-time option to a runtime option. This should make it easy to assess the performance impact of such a change without having to custom-build. PR-URL: https://github.com/nodejs/node/pull/30954 Reviewed-By: Ben Noordhuis Reviewed-By: David Carlier Reviewed-By: David Carlier Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: Denys Otrishko Co-authored-by: David Carlier --- configure.py | 33 ----------------------- doc/api/cli.md | 17 ++++++++++++ doc/node.1 | 10 +++++++ node.gyp | 5 ++-- node.gypi | 6 ++--- src/large_pages/node_large_page.cc | 19 +++++++------ src/node.cc | 30 ++++++++++++++------- src/node_options.cc | 9 +++++++ src/node_options.h | 1 + test/parallel/test-startup-large-pages.js | 29 ++++++++++++++++++++ 10 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 test/parallel/test-startup-large-pages.js diff --git a/configure.py b/configure.py index 5c1360615de6b3..e53d7d86843d84 100755 --- a/configure.py +++ b/configure.py @@ -424,17 +424,6 @@ dest='with_etw', help='build with ETW (default is true on Windows)') -parser.add_option('--use-largepages', - action='store_true', - dest='node_use_large_pages', - help='build with Large Pages support. This feature is supported only on Linux kernel' + - '>= 2.6.38 with Transparent Huge pages enabled and FreeBSD') - -parser.add_option('--use-largepages-script-lld', - action='store_true', - dest='node_use_large_pages_script_lld', - help='link against the LLVM ld linker script. Implies -fuse-ld=lld in the linker flags') - intl_optgroup.add_option('--with-intl', action='store', dest='with_intl', @@ -1092,28 +1081,6 @@ def configure_node(o): else: o['variables']['node_use_dtrace'] = 'false' - if options.node_use_large_pages and not flavor in ('linux', 'freebsd', 'mac'): - raise Exception( - 'Large pages are supported only on Linux, FreeBSD and MacOS Systems.') - if options.node_use_large_pages and flavor in ('linux', 'freebsd', 'mac'): - if options.shared or options.enable_static: - raise Exception( - 'Large pages are supported only while creating node executable.') - if target_arch!="x64": - raise Exception( - 'Large pages are supported only x64 platform.') - if flavor == 'mac': - info('macOS server with 32GB or more is recommended') - if flavor == 'linux': - # Example full version string: 2.6.32-696.28.1.el6.x86_64 - FULL_KERNEL_VERSION=os.uname()[2] - KERNEL_VERSION=FULL_KERNEL_VERSION.split('-')[0] - if KERNEL_VERSION < "2.6.38" and flavor == 'linux': - raise Exception( - 'Large pages need Linux kernel version >= 2.6.38') - o['variables']['node_use_large_pages'] = b(options.node_use_large_pages) - o['variables']['node_use_large_pages_script_lld'] = b(options.node_use_large_pages_script_lld) - if options.no_ifaddrs: o['defines'] += ['SUNOS_NO_IFADDRS'] diff --git a/doc/api/cli.md b/doc/api/cli.md index 2f3c6a9f7da114..f887a3940ea530 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -900,6 +900,22 @@ environment variables. See `SSL_CERT_DIR` and `SSL_CERT_FILE`. +### `--use-largepages=mode` + + +Re-map the Node.js static code to large memory pages at startup. If supported on +the target system, this will cause the Node.js static code to be moved onto 2 +MiB pages instead of 4 KiB pages. + +The following values are valid for `mode`: +* `off`: No mapping will be attempted. This is the default. +* `on`: If supported by the OS, mapping will be attempted. Failure to map will + be ignored and a message will be printed to standard error. +* `silent`: If supported by the OS, mapping will be attempted. Failure to map + will be ignored and will not be reported. + ### `--v8-options`