@@ -2013,6 +2013,32 @@ On a machine with 2 GiB of memory, consider setting this to
2013
2013
$ node --max-old-space-size=1536 index.js
2014
2014
```
2015
2015
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
2016
2042
[ Chrome DevTools Protocol ] : https://chromedevtools.github.io/devtools-protocol/
2017
2043
[ CommonJS ] : modules.md
2018
2044
[ ECMAScript module loader ] : esm.md#loaders
@@ -2038,6 +2064,7 @@ $ node --max-old-space-size=1536 index.js
2038
2064
[ `NODE_OPTIONS` ] : #node_optionsoptions
2039
2065
[ `NO_COLOR` ] : https://no-color.org
2040
2066
[ `SlowBuffer` ] : buffer.md#class-slowbuffer
2067
+ [ `YoungGenerationSizeFromSemiSpaceSize` ] : https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
2041
2068
[ `dns.lookup()` ] : dns.md#dnslookuphostname-options-callback
2042
2069
[ `dns.setDefaultResultOrder()` ] : dns.md#dnssetdefaultresultorderorder
2043
2070
[ `dnsPromises.lookup()` ] : dns.md#dnspromiseslookuphostname-options
@@ -2057,6 +2084,8 @@ $ node --max-old-space-size=1536 index.js
2057
2084
[ libuv threadpool documentation ] : https://docs.libuv.org/en/latest/threadpool.html
2058
2085
[ remote code execution ] : https://www.owasp.org/index.php/Code_Injection
2059
2086
[ 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
2060
2088
[ security warning ] : #warning-binding-inspector-to-a-public-ipport-combination-is-insecure
2089
+ [ semi-space ] : https://www.memorymanagement.org/glossary/s.html#semi.space
2061
2090
[ timezone IDs ] : https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
2062
2091
[ ways that `TZ` is handled in other environments ] : https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
0 commit comments