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 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 、 纸存储服务器 的固定时间框架, 在运行中, 我们的存储服务器上, 将 的存储 的存储 的 保存 的存储 的 的 保存 的 的 保存到 格式, 保存到 格式, 保存到 保存到 的 的 服务器的 。