--max-semi-space-size=SIZE(以兆字节为单位)
【--max-semi-space-size=SIZE (in megabytes)】
设置 V8 的 清理垃圾收集器 的最大 半空格 大小,单位为 MiB(兆字节)。 增加半空间的最大大小可能会提高 Node.js 的吞吐量,但代价是更多的内存消耗。
【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.】
由于 V8 堆的年轻代大小是半空间的三倍(参见 V8 中的 YoungGenerationSizeFromSemiSpaceSize),每增加 1 MiB 的半空间,会应用到三个独立的半空间,因此堆大小将增加 3 MiB。吞吐量的提高取决于你的工作负载(参见 #42511)。
【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).】
默认值为64位系统16 MiB,32位系统8 MiB。为了获得适合你应用的最佳配置,你应该在运行应用基准测试时尝试不同的 max-semi-space-size 值。
【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.】
例如,在 64 位系统上进行基准测试:
【For example, benchmark on a 64-bit systems:】
for MiB in 16 32 64 128; do
node --max-semi-space-size=$MiB index.js
done