Skip to content

Commit a23051a

Browse files
JialuZhang-inteltargos
authored andcommitted
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 66ee1f1 commit a23051a

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
@@ -2034,6 +2034,32 @@ On a machine with 2 GiB of memory, consider setting this to
20342034
$ node --max-old-space-size=1536 index.js
20352035
```
20362036

2037+
### `--max-semi-space-size=SIZE` (in megabytes)
2038+
2039+
Sets the maximum [semi-space][] size for V8's [scavenge garbage collector][] in
2040+
MiB (megabytes).
2041+
Increasing the max size of a semi-space may improve throughput for Node.js at
2042+
the cost of more memory consumption.
2043+
2044+
Since the young generation size of the V8 heap is three times (see
2045+
[`YoungGenerationSizeFromSemiSpaceSize`][] in V8) the size of the semi-space,
2046+
an increase of 1 MiB to semi-space applies to each of the three individual
2047+
semi-spaces and causes the heap size to increase by 3 MiB. The throughput
2048+
improvement depends on your workload (see [#42511][]).
2049+
2050+
The default value is 16 MiB for 64-bit systems and 8 MiB for 32-bit systems. To
2051+
get the best configuration for your application, you should try different
2052+
max-semi-space-size values when running benchmarks for your application.
2053+
2054+
For example, benchmark on a 64-bit systems:
2055+
2056+
```bash
2057+
for MiB in 16 32 64 128; do
2058+
node --max-semi-space-size=$MiB index.js
2059+
done
2060+
```
2061+
2062+
[#42511]: https://github.com/nodejs/node/issues/42511
20372063
[Chrome DevTools Protocol]: https://chromedevtools.github.io/devtools-protocol/
20382064
[CommonJS]: modules.md
20392065
[ECMAScript module loader]: esm.md#loaders
@@ -2059,6 +2085,7 @@ $ node --max-old-space-size=1536 index.js
20592085
[`NODE_OPTIONS`]: #node_optionsoptions
20602086
[`NO_COLOR`]: https://no-color.org
20612087
[`SlowBuffer`]: buffer.md#class-slowbuffer
2088+
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
20622089
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
20632090
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder
20642091
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
@@ -2078,6 +2105,8 @@ $ node --max-old-space-size=1536 index.js
20782105
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
20792106
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
20802107
[running tests from the command line]: test.md#running-tests-from-the-command-line
2108+
[scavenge garbage collector]: https://v8.dev/blog/orinoco-parallel-scavenger
20812109
[security warning]: #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
2110+
[semi-space]: https://www.memorymanagement.org/glossary/s.html#semi.space
20822111
[timezone IDs]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
20832112
[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)