--max-semi-space-size=SIZE(以兆字节为单位)
【--max-semi-space-size=SIZE (in MiB)】
设置 V8 的 清理垃圾收集器 的最大 半空格 大小,单位为 MiB(兆二进制字节)。 增加半空间的最大大小可能会提高 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。对于内存限制最高为 2 GiB 的系统,在 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