Optimal Heap Limits for Reducing Browser Memory Use

04/22/2022
by   Marisa Kirisame, et al.
0

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 garbage collection time are possible with no change in total memory usage.

READ FULL TEXT

Please sign up or login with your details

Forgot password? Click here to reset