--max-semi-space-size=SIZE(以 MiB 为单位)


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

以 MiB(兆字节)为单位设置 V8 的 清除垃圾收集器 的最大 semi-space 大小。增加半空间的最大尺寸可能会提高 Node.js 的吞吐量,但会消耗更多内存。

¥Sets the maximum semi-space size for V8's scavenge garbage collector in MiB (mebibytes). 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).

默认值取决于内存限制。例如,在内存限制为 512 MiB 的 64 位系统上,半空间的最大大小默认为 1 MiB。对于高达 2GiB 的内存限制,在 64 位系统上,半空间的默认最大大小将小于 16 MiB。

¥The default value depends on the memory limit. For example, on 64-bit systems with a memory limit of 512 MiB, the max size of a semi-space defaults to 1 MiB. For memory limits up to and including 2GiB, the default max size of a semi-space will be less than 16 MiB on 64-bit systems.

要为你的应用获得最佳配置,你应该在为你的应用运行基准测试时尝试不同的 max-semi-space-size 值。

¥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