Skip to content

Commit 65622bf

Browse files
author
Gabriel Schulhof
committed
src: make --use-largepages a three-valued option
1 parent a83c5df commit 65622bf

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

doc/api/cli.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ environment variables.
863863

864864
See `SSL_CERT_DIR` and `SSL_CERT_FILE`.
865865

866-
### `--use-largepages`
866+
### `--use-largepages=num`
867867
<!-- YAML
868868
added: REPLACEME
869869
-->
@@ -872,6 +872,13 @@ Re-map the Node.js static code to large memory pages at startup. If supported on
872872
the target system, this will cause the Node.js static code to be moved onto 2
873873
MiB pages instead of 4 KiB pages.
874874

875+
The following values are valid for `num`:
876+
* 0: No mapping will be attempted. This is the default.
877+
* 1: If supported by the OS, mapping will be attempted. Failure to map will be
878+
ignored and will not be reported.
879+
* 2: If supported by the OS, mapping will be attempted. Failure to map will be
880+
ignored and a message will be printed to standard error.
881+
875882
### `--v8-options`
876883
<!-- YAML
877884
added: v0.1.3

doc/node.1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,12 @@ See
398398
and
399399
.Ev SSL_CERT_FILE .
400400
.
401-
.It Fl -use-largepages
401+
.It Fl -use-largepages Ns = Ns Ar num
402402
Re-map the Node.js static code to large memory pages at startup. If supported on
403403
the target system, this will cause the Node.js static code to be moved onto 2
404404
MiB pages instead of 4 KiB pages.
405+
.Pp
406+
The following values are valid: 0 (do not map), 1 (map, ignore failure, and do not report it), and 2 (map, ignore failure, but report it to standard error).
405407
.
406408
.It Fl -v8-options
407409
Print V8 command-line options.

src/node.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,11 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) {
984984
}
985985
}
986986

987-
if (per_process::cli_options->use_largepages) {
987+
if (per_process::cli_options->use_largepages == 1 ||
988+
per_process::cli_options->use_largepages == 2) {
988989
if (node::IsLargePagesEnabled()) {
989-
if (node::MapStaticCodeToLargePages() != 0) {
990+
if (node::MapStaticCodeToLargePages() != 0 &&
991+
per_process::cli_options->use_largepages == 2) {
990992
fprintf(stderr, "Reverting to default page size\n");
991993
}
992994
}

src/node_options.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) {
6363
"used, not both");
6464
}
6565
#endif
66+
if (!(use_largepages >= 0 && use_largepages <= 2)) {
67+
errors->push_back("--use-largepages must be one of 0, 1, or 2");
68+
}
6669
per_isolate->CheckOptions(errors);
6770
}
6871

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class PerProcessOptions : public Options {
235235
bool force_fips_crypto = false;
236236
#endif
237237
#endif
238-
bool use_largepages = false;
238+
uint64_t use_largepages = 0;
239239

240240
#ifdef NODE_REPORT
241241
std::vector<std::string> cmdline;

0 commit comments

Comments
 (0)