Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
convert values to strings
  • Loading branch information
Gabriel Schulhof committed Dec 17, 2019
commit 764c1096a7a3d1e3580ff8b555b20999626b69ce
14 changes: 7 additions & 7 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ environment variables.

See `SSL_CERT_DIR` and `SSL_CERT_FILE`.

### `--use-largepages=num`
### `--use-largepages=mode`
<!-- YAML
added: REPLACEME
-->
Expand All @@ -872,12 +872,12 @@ 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 `num`:
* 0: No mapping will be attempted. This is the default.
* 1: If supported by the OS, mapping will be attempted. Failure to map will be
ignored and will not be reported.
* 2: If supported by the OS, mapping will be attempted. Failure to map will be
ignored and a message will be printed to standard error.
The following values are valid for `mode`:
* `off`: No mapping will be attempted. This is the default.
* `silent`: If supported by the OS, mapping will be attempted. Failure to map
will be ignored and will not be reported.
* `verbose`: If supported by the OS, mapping will be attempted. Failure to map
Comment thread
gabrielschulhof marked this conversation as resolved.
Outdated
will be ignored and a message will be printed to standard error.

### `--v8-options`
<!-- YAML
Expand Down
7 changes: 5 additions & 2 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,15 @@ See
and
.Ev SSL_CERT_FILE .
.
.It Fl -use-largepages Ns = Ns Ar num
.It Fl -use-largepages Ns = Ns Ar 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.
.Pp
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).
.Ar mode
must have one of the following values:
`off` (do not map), `silent` (map and ignore failure without reporting it), or
`verbose` (map and ignore failure, but report it to standard error).
.
.It Fl -v8-options
Print V8 command-line options.
Expand Down
10 changes: 5 additions & 5 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -985,21 +985,21 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) {
}

#if defined(NODE_ENABLE_LARGE_CODE_PAGES) && NODE_ENABLE_LARGE_CODE_PAGES
if (per_process::cli_options->use_largepages == 1 ||
per_process::cli_options->use_largepages == 2) {
if (per_process::cli_options->use_largepages == "silent" ||
per_process::cli_options->use_largepages == "verbose") {
if (node::IsLargePagesEnabled()) {
Comment thread
gabrielschulhof marked this conversation as resolved.
if (node::MapStaticCodeToLargePages() != 0 &&
per_process::cli_options->use_largepages == 2) {
per_process::cli_options->use_largepages == "verbose") {
fprintf(stderr,
"Mapping code to large pages failed. Reverting to default page "
"size.\n");
}
} else if (per_process::cli_options->use_largepages == 2) {
} else if (per_process::cli_options->use_largepages == "verbose") {
fprintf(stderr, "Large pages are not enabled.\n");
}
}
#else
if (per_process::cli_options->use_largepages == 2) {
if (per_process::cli_options->use_largepages == "verbose") {
fprintf(stderr, "Mapping to large pages is not supported.\n");
}
#endif // NODE_ENABLE_LARGE_CODE_PAGES
Expand Down
6 changes: 4 additions & 2 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) {
"used, not both");
}
#endif
if (!(use_largepages >= 0 && use_largepages <= 2)) {
errors->push_back("--use-largepages must be one of 0, 1, or 2");
if (use_largepages != "off" &&
use_largepages != "silent" &&
use_largepages != "verbose") {
errors->push_back("invalid value for --use-largepages");
}
per_isolate->CheckOptions(errors);
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class PerProcessOptions : public Options {
bool force_fips_crypto = false;
#endif
#endif
uint64_t use_largepages = 0;
std::string use_largepages = "off";

#ifdef NODE_REPORT
std::vector<std::string> cmdline;
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-startup-large-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { spawnSync } = require('child_process');

{
const child = spawnSync(process.execPath,
[ '--use-largepages=1', '-p', '42' ]);
[ '--use-largepages=silent', '-p', '42' ]);
const stdout = child.stdout.toString().match(/\S+/g);
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
Expand All @@ -18,11 +18,11 @@ const { spawnSync } = require('child_process');

{
const child = spawnSync(process.execPath,
[ '--use-largepages=3', '-p', '42' ]);
[ '--use-largepages=xyzzy', '-p', '42' ]);
assert.strictEqual(child.status, 9);
assert.strictEqual(child.signal, null);
assert.strictEqual(child.stderr.toString().match(/\S+/g).slice(1).join(' '),
'--use-largepages must be one of 0, 1, or 2');
'invalid value for --use-largepages');
}

// TODO(gabrielschulhof): Run with --use-largepages=2 and make assertions about
Comment thread
gabrielschulhof marked this conversation as resolved.
Outdated
Expand Down