--max-semi-space-size=SIZE(以兆字节为单位)


¥--max-semi-space-size=SIZE (in megabytes)

以 MiB(兆字节)为单位设置 V8 的 清除垃圾收集器 的最大 semi-space 大小。增加半空间的最大尺寸可能会提高 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