arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2204.10455cs.PLcs.SYeess.SY
收藏

减少浏览器内存使用的最佳堆限制

Optimal Heap Limits for Reducing Browser Memory Use

Marisa Kirisame, Pranav Shenoy, Pavel Panchekha

摘要:

垃圾收集语言运行时会仔细调优堆限制,以减少垃圾回收时间和内存使用。然而,这是一个折衷:较低的堆限制减少了内存使用,但增加了垃圾回收时间。设置堆限制的经典方法包括手动调优堆限制和多个实时大小的经验法则,但尚不清楚何时一个规则优于另一个规则或如何比较它们。我们用一个新的框架来解决这个问题,在这个框架中,一次为多个堆设置堆限制。我们的关键见解是,每个堆限制规则都会导致跨多个进程的特定内存分配,并且这种分配可能是次优的。我们使用我们的框架来推导出最佳的“平方根”堆限制规则,该规则可以在任何总垃圾回收时间内最小化总内存使用量。奇怪的是,平方根堆限制规则在没有通信的情况下实现了这种协调:它在多个堆之间最优地分配内存,而不需要这些堆之间的任何通信。为了证明这个堆限制规则是有效的,我们为V8(Google Chrome、微软Edge和其他浏览器中使用的JavaScript运行时)以及服务器端框架(如node.js和Deno)建立了原型。在现实世界的网页,我们的原型实现了约16.0%的内存使用减少,同时保持垃圾回收时间不变。在内存密集型基准测试中,可以在不改变总内存使用量的情况下减少多达30.0%的垃圾回收时间。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑