Skip to content

Commit f7770ed

Browse files
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 ef70718 commit f7770ed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Diff for: doc/api/cli.md

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

2050+
### `--max-semi-space-size=SIZE` (in megabytes)
2051+
2052+
Sets the maximum [semi-space][] size for V8's [scavenge garbage collector][] in
2053+
MiB (megabytes).
2054+
Increasing the max size of a semi-space may improve throughput for Node.js at
2055+
the cost of more memory consumption.
2056+
2057+
Since the young generation size of the V8 heap is three times (see
2058+
[`YoungGenerationSizeFromSemiSpaceSize`][] in V8) the size of the semi-space,
2059+
an increase of 1 MiB to semi-space applies to each of the three individual
2060+
semi-spaces and causes the heap size to increase by 3 MiB. The throughput
2061+
improvement depends on your workload (see [#42511][]).
2062+
2063+
The default value is 16 MiB for 64-bit systems and 8 MiB for 32-bit systems. To
2064+
get the best configuration for your application, you should try different
2065+
max-semi-space-size values when running benchmarks for your application.
2066+
2067+
For example, benchmark on a 64-bit systems:
2068+
2069+
```bash
2070+
for MiB in 16 32 64 128; do
2071+
node --max-semi-space-size=$MiB index.js
2072+
done
2073+
```
2074+
2075+
[#42511]: https://github.com/nodejs/node/issues/42511
20502076
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
20512077
[CommonJS]: modules.md
20522078
[ECMAScript module loader]: esm.md#loaders
@@ -2073,6 +2099,7 @@ $ node --max-old-space-size=1536 index.js
20732099
[`NODE_OPTIONS`]: #node_optionsoptions
20742100
[`NO_COLOR`]: https://no-color.org
20752101
[`SlowBuffer`]: buffer.md#class-slowbuffer
2102+
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
20762103
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
20772104
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder
20782105
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
@@ -2092,6 +2119,8 @@ $ node --max-old-space-size=1536 index.js
20922119
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
20932120
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
20942121
[running tests from the command line]: test.md#running-tests-from-the-command-line
2122+
[scavenge garbage collector]: https://v8.dev/blog/orinoco-parallel-scavenger
20952123
[security warning]: #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
2124+
[semi-space]: https://www.memorymanagement.org/glossary/s.html#semi.space
20962125
[timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
20972126
[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)