Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add new useful V8 option #42575

Merged
merged 21 commits into from
Jun 17, 2022
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a28ef1b
doc: add new useful V8 option
JialuZhang-intel Apr 2, 2022
b960c66
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
3ae0f49
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
6813f99
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
7b1739c
Update doc/api/cli.md
JialuZhang-intel Apr 2, 2022
dddff28
Apply suggestions from code review
JialuZhang-intel Apr 3, 2022
a05b327
Update doc/api/cli.md
JialuZhang-intel Apr 8, 2022
eb1eec7
Remove recommended value for max_semi_space_size
JialuZhang-intel May 5, 2022
d1defe3
Merge branch 'nodejs:master' into document_max_semi_space_size
JialuZhang-intel May 5, 2022
91a151a
doc: update format for cli.md
JialuZhang-intel May 5, 2022
0dfd5e5
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
f91e536
Apply suggestions from code review
JialuZhang-intel May 5, 2022
1bb2ad7
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
4fc45b6
doc: add new useful V8 option
JialuZhang-intel May 5, 2022
e1c0732
Apply suggestions from code review
JialuZhang-intel May 6, 2022
4ef953f
Update doc/api/cli.md
JialuZhang-intel Jun 12, 2022
5574419
Update doc/api/cli.md
JialuZhang-intel Jun 13, 2022
1deaca4
Merge branch 'nodejs:master' into document_max_semi_space_size
JialuZhang-intel Jun 13, 2022
db7d07d
doc: add new useful V8 option
JialuZhang-intel Jun 13, 2022
baa9c9b
Merge branch 'document_max_semi_space_size' of https://github.com/Jia…
JialuZhang-intel Jun 13, 2022
5411215
doc: add new useful V8 option
JialuZhang-intel Jun 13, 2022
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
29 changes: 29 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,32 @@ On a machine with 2 GiB of memory, consider setting this to
$ node --max-old-space-size=1536 index.js
```

### `--max-semi-space-size=SIZE` (in megabytes)

Sets the maximum [semi-space][] size for V8's [scavenge garbage collector][] in
MiB (megabytes).
Increasing the max size of a semi-space may improve throughput for Node.js at
the cost of more memory consumption.

Since the young generation size of the V8 heap is three times (see
[`YoungGenerationSizeFromSemiSpaceSize`][] in V8) the size of the semi-space,
an increase of 1 MiB to semi-space applies to each of the three individual
semi-spaces and causes the heap size to increase by 3 MiB. The throughput
improvement depends on your workload (see [#42511][]).

The default value is 16 MiB for 64-bit systems and 8 MiB for 32-bit systems. To
get the best configuration for your application, you should try different
max-semi-space-size values when running benchmarks for your application.

For example, benchmark on a 64-bit systems:

```bash
for MiB in 16 32 64 128; do
node --max-semi-space-size=$MiB index.js
done
JialuZhang-intel marked this conversation as resolved.
Show resolved Hide resolved
```

[#42511]: https://github.com/nodejs/node/issues/42511
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
[CommonJS]: modules.md
[ECMAScript module loader]: esm.md#loaders
Expand All @@ -2073,6 +2099,7 @@ $ node --max-old-space-size=1536 index.js
[`NODE_OPTIONS`]: #node_optionsoptions
[`NO_COLOR`]: https://no-color.org
[`SlowBuffer`]: buffer.md#class-slowbuffer
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
Expand All @@ -2092,6 +2119,8 @@ $ node --max-old-space-size=1536 index.js
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
[running tests from the command line]: test.md#running-tests-from-the-command-line
[scavenge garbage collector]: https://v8.dev/blog/orinoco-parallel-scavenger
[security warning]: #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
[semi-space]: https://www.memorymanagement.org/glossary/s.html#semi.space
[timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
[ways that `TZ` is handled in other environments]: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html