Garbage collected language runtimes must 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-working-memory rules of thumb. But because it's a trade-off, it's not clear what heap limit rule is best or how even to compare them. We address this problem with a new framework where heap limits are set for multiple heaps at once. In this framework, standard heap limit rules are non-compositional: multiple heaps using the same heap limit rule allocate memory in non-Pareto-optimal ways. We use our framework to derive a compositional "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 coordination without communication: it allocates memory optimally across multiple heaps without requiring any communication between 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.99% of memory usage. On memory-intensive benchmarks, reductions of up to 6.55% of garbage collection time are possible with no change in total memory usage.
翻译:收集的垃圾语言运行时间必须小心调整堆积限制, 以减少垃圾收集时间和记忆使用。 但是, 存在一个权衡: 低的堆积限制会减少记忆用量, 增加垃圾收集时间。 设定堆积限制的经典方法包括手动调整的堆积限制和多工作模拟大拇指规则。 但是, 因为它是一个权衡, 并不清楚什么是堆积限制规则是最好的, 或者如何比较它们。 我们用一个新的框架解决这个问题, 即为多个堆积堆积标准设定了堆积限制。 在此框架中, 标准堆积限制规则是非组合的: 使用相同的堆积限制规则来减少记忆使用量, 使用相同的堆积规则来分配内存。 利用我们的框架来得出一个“ 平整的” 堆积限制规则, 从而在垃圾收集的任何时间中最大限度地减少总记忆用量。 奇怪的是, 平庸俗化的堆积限制规则可以在没有通讯的情况下实现协调: 它在多个堆积的堆积页内分配最理想的记忆, 大约不需要任何平时段的 。 。 在纸化的服务器上, 显示这个规则在预 。