Skip to content

Commit 20fa30c

Browse files
JialuZhang-inteltargos
authored andcommittedJul 31, 2022
doc: add new useful V8 option
Add the `--max_semi_space_size` flag into useful V8 option. Fixes: #42511 PR-URL: #42575 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent c4dc8b6 commit 20fa30c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
 

‎doc/api/cli.md

+29
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,32 @@ On a machine with 2 GiB of memory, consider setting this to
20132013
$ node --max-old-space-size=1536 index.js
20142014
```
20152015

2016+
### `--max-semi-space-size=SIZE` (in megabytes)
2017+
2018+
Sets the maximum [semi-space][] size for V8's [scavenge garbage collector][] in
2019+
MiB (megabytes).
2020+
Increasing the max size of a semi-space may improve throughput for Node.js at
2021+
the cost of more memory consumption.
2022+
2023+
Since the young generation size of the V8 heap is three times (see
2024+
[`YoungGenerationSizeFromSemiSpaceSize`][] in V8) the size of the semi-space,
2025+
an increase of 1 MiB to semi-space applies to each of the three individual
2026+
semi-spaces and causes the heap size to increase by 3 MiB. The throughput
2027+
improvement depends on your workload (see [#42511][]).
2028+
2029+
The default value is 16 MiB for 64-bit systems and 8 MiB for 32-bit systems. To
2030+
get the best configuration for your application, you should try different
2031+
max-semi-space-size values when running benchmarks for your application.
2032+
2033+
For example, benchmark on a 64-bit systems:
2034+
2035+
```bash
2036+
for MiB in 16 32 64 128; do
2037+
node --max-semi-space-size=$MiB index.js
2038+
done
2039+
```
2040+
2041+
[#42511]: https://github.com/nodejs/node/issues/42511
20162042
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
20172043
[CommonJS]: modules.md
20182044
[ECMAScript module loader]: esm.md#loaders
@@ -2038,6 +2064,7 @@ $ node --max-old-space-size=1536 index.js
20382064
[`NODE_OPTIONS`]: #node_optionsoptions
20392065
[`NO_COLOR`]: https://no-color.org
20402066
[`SlowBuffer`]: buffer.md#class-slowbuffer
2067+
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
20412068
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
20422069
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder
20432070
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
@@ -2057,6 +2084,8 @@ $ node --max-old-space-size=1536 index.js
20572084
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
20582085
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
20592086
[running tests from the command line]: test.md#running-tests-from-the-command-line
2087+
[scavenge garbage collector]: https://v8.dev/blog/orinoco-parallel-scavenger
20602088
[security warning]: #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
2089+
[semi-space]: https://www.memorymanagement.org/glossary/s.html#semi.space
20612090
[timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
20622091
[ways that `TZ` is handled in other environments]: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

0 commit comments

Comments
 (0)
Please sign in to comment.