Garbage-collected language runtimes carefully tune heap limits to reduce garbage collection time and memory usage. However, there's a trade-off: a lower heap limit reduces memory use but increases garbage collection time. Classic methods for setting heap limits include manually tuned heap limits and multiple-of-live-size rules of thumb, but it is not clear when one rule is better than another or how to compare them. We address this problem with a new framework where heap limits are set for multiple heaps at once. Our key insight is that every heap limit rule induces a particular allocation of memory across multiple processes, and this allocation can be sub-optimal. We use our framework to derive an optimal "square-root" heap limit rule, which achieves minimizes total memory usage for any amount of total garbage collection time. Paradoxically, the square-root heap limit rule achieves this coordination without communication: it allocates memory optimally across multiple heaps without requiring any communication between those heaps. To demonstrate that this heap limit rule is effective, we prototype it for V8, the JavaScript runtime used in Google Chrome, Microsoft Edge, and other browsers, as well as in server-side frameworks like node.js and Deno. On real-world web pages, our prototype achieves reductions of approximately 16.0% of memory usage while keeping garbage collection time constant. On memory-intensive benchmarks, reductions of up to 30.0% of garbage collection time are possible with no change in total memory usage.
翻译:垃圾收集语言运行时小心调整堆积限制,以减少垃圾收集时间和记忆用量。然而,有一个折中点:一个更低的堆积限制会减少记忆用量,但会增加垃圾收集时间。一个典型的堆积限制设置方法包括手动调整的堆积限制和多个活体大小的拇指规则,但不清楚一个规则何时优于另一个规则,或如何进行比较。我们用一个新的框架解决这个问题,即同时为多个堆积堆设定了堆积限制。我们的关键洞察力是,每个堆积限制规则会给多个进程带来特定的内存分配,而这种分配可能是次最佳的。我们使用这个框架来得出一个最佳的“平流”堆积限制规则,这可以最大限度地减少垃圾收集时间的总量。奇怪的是,平底层的堆积限制规则可以在不沟通的情况下实现这种协调:它最妥善地将记忆分配到多个堆积的堆积基准,而不需要这些堆积之间的任何交流。为了表明这个堆积规则是有效的,我们在 V8,我们固定的存储服务器上, 将它原点的缩缩缩缩缩缩成成一个总的时间框架,在了我们的缩缩存储服务器里。