skip to main content
research-article
Open Access

Optimal heap limits for reducing browser memory use

Published:31 October 2022Publication History
Skip Abstract Section

Abstract

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.

References

  1. Ayush Agarwal, Sioli O’Connell, Jason Kim, Shaked Yehezkel, Daniel Genkin, Eyal Ronen, and Yuval Yarom. 2022. Spook.js: Attacking Chrome Strict Site Isolation via Speculative Execution. In 43rd IEEE Symposium on Security and Privacy (S&P’22). 93–101. https://doi.org/10.1109/SP46214.2022.9833711 Google ScholarGoogle ScholarCross RefCross Ref
  2. Martin Aigner, Thomas Hütter, Christoph M Kirsch, Alexander Miller, Hannes Payer, and Mario Preishuber. 2014. ACDC-JS: explorative benchmarking of javascript memory management. ACM SIGPLAN Notices, 50, 2 (2014), 67–78. https://doi.org/10.1145/2661088.2661089 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Mythri Alle, Dan Elphick, and Ross McIlroy. 2019. A Lighter V8. https://v8.dev/blog/v8-lite Google ScholarGoogle Scholar
  4. Raphael Alonso and Andrew W. Appel. 1990. An Advisor for Flexible Working Sets. SIGMETRICS ’90. Association for Computing Machinery, New York, NY, USA. 153–162. isbn:0897913590 https://doi.org/10.1145/98457.98753 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Edd Barrett, Carl Friedrich Bolz-Tereick, Rebecca Killick, Vincent Knight, Sarah Mount, and Laurence Tratt. 2017. Virtual Machine Warmup Blows Hot and Cold. In OOPSLA. ACM, 27 pages. https://doi.org/10.1145/3133876 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Tim Brecht, Eshrat Arjomandi, Chang Li, and Hang Pham. 2006. Controlling Garbage Collection and Heap Growth to Reduce the Execution Time of Java Applications. ACM Trans. Program. Lang. Syst., 28, 5 (2006), sep, 908–941. issn:0164-0925 https://doi.org/10.1145/1152649.1152652 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Preston Briggs, Keith D. Cooper, and Linda Torczon. 1992. Rematerialization. SIGPLAN Not., 27, 7 (1992), jul, 311–321. issn:0362-1340 https://doi.org/10.1145/143103.143143 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Callum Cameron, Jeremy Singer, and David Vengerov. 2015. The Judgment of Forseti: Economic Utility for Dynamic Heap Sizing of Multiple Runtimes. SIGPLAN Not., 50, 11 (2015), jun, 143–156. issn:0362-1340 https://doi.org/10.1145/2887746.2754180 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle Time Garbage Collection Scheduling. SIGPLAN Not., 51, 6 (2016), Jun, 570–583. issn:0362-1340 https://doi.org/10.1145/2980983.2908106 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ulan Degenbaev, Jochen Eisinger, Kentaro Hara, Marcel Hlopko, Michael Lippautz, and Hannes Payer. 2018. Cross-Component Garbage Collection. Proc. ACM Program. Lang., 2, OOPSLA (2018), Article 151, oct, 24 pages. https://doi.org/10.1145/3276521 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ulan Degenbaev, Michael Lippautz, and Hannes Payer. 2018. Concurrent marking in V8. https://v8.dev/blog/concurrent-marking Google ScholarGoogle Scholar
  12. Ulan Degenbaev, Michael Lippautz, and Hannes Payer. 2019. Concurrent Marking of Shape-Changing Objects. ISMM 2019. Association for Computing Machinery, New York, NY, USA. 89–102. isbn:9781450367226 https://doi.org/10.1145/3315573.3329978 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Matthew Flatt. 2022. cs: experiment with a revised major-GC trigger. https://github.com/racket/racket/commit/157b1f30a1501d53d310cbe0d9bb999a81c689e7 Google ScholarGoogle Scholar
  14. Matthew Flatt and PLT. 2010. Reference: Racket. PLT Design Inc.. https://racket-lang.org/tr1/ Google ScholarGoogle Scholar
  15. Matthew Hertz and Emery D. Berger. 2005. Quantifying the Performance of Garbage Collection vs. Explicit Memory Management. SIGPLAN Not., 40, 10 (2005), Oct, 313–326. issn:0362-1340 https://doi.org/10.1145/1103845.1094836 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Matthew Hertz, Yi Feng, and Emery D. Berger. 2005. Garbage Collection without Paging. In Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’05). Association for Computing Machinery, New York, NY, USA. 143–153. isbn:1595930566 https://doi.org/10.1145/1065010.1065028 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Matthew Hertz, Stephen Kane, Elizabeth Keudel, Tongxin Bai, Chen Ding, Xiaoming Gu, and Jonathan E. Bard. 2011. Waste Not, Want Not: Resource-Based Garbage Collection in a Shared Environment. In Proceedings of the International Symposium on Memory Management (ISMM ’11). Association for Computing Machinery, New York, NY, USA. 65–76. isbn:9781450302630 https://doi.org/10.1145/1993478.1993487 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Richard Jones, Antony Hosking, and Eliot Moss. 2012. The Garbage Collection Handbook (1 ed.). Chapman and Haii/CRC, Taylor and Francis Group, 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742. Google ScholarGoogle Scholar
  19. Marisa Kirisame, Steven Lyubomirsky, Altan Haan, Jennifer Brennan, Mike He, Jared Roesch, Tianqi Chen, and Zachary Tatlock. 2021. Dynamic Tensor Rematerialization. In International Conference on Learning Representations. 31 pages. https://doi.org/10.48550/ARXIV.2006.09616 Google ScholarGoogle Scholar
  20. David Lion, Adrian Chiu, and Ding Yuan. 2021. M3: End-to-End Memory Management in Elastic System Software Stacks. In Proceedings of the Sixteenth European Conference on Computer Systems (EuroSys ’21). Association for Computing Machinery, New York, NY, USA. 507–522. isbn:9781450383349 https://doi.org/10.1145/3447786.3456256 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. John McCarthy. 1960. Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I. Commun. ACM, 3, 4 (1960), apr, 184–195. issn:0001-0782 https://doi.org/10.1145/367177.367199 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Mozilla. 2020. Are We Slim Yet. http://udn.realityripple.com/docs/Mozilla/Performance/AWSY Google ScholarGoogle Scholar
  23. Mozilla. 2022. FireFox MemBalancer. https://bugzilla.mozilla.org/show_bug.cgi?id=1770763 Google ScholarGoogle Scholar
  24. Diogenes Nunez, Samuel Z. Guyer, and Emery D. Berger. 2016. Prioritized garbage collection: explicit GC support for software caches. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, part of SPLASH 2016, Amsterdam, The Netherlands, October 30 - November 4, 2016, Eelco Visser and Yannis Smaragdakis (Eds.). ACM, 695–710. https://doi.org/10.1145/2983990.2984028 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Oracle. 2015. Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide. https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ Google ScholarGoogle Scholar
  26. Xinli Shang. 2020. Tricks of the trade: Tuning JVM memory for large-scale services. https://eng.uber.com/jvm-tuning-garbage-collection/ Google ScholarGoogle Scholar
  27. Ayush Vij. 2022. Reduce chrome memory usage and make it use less Ram. https://www.thewindowsclub.com/reduce-chrome-memory-usage-make-it-use-less-ram Google ScholarGoogle Scholar
  28. Ting Yang, Matthew Hertz, Emery D. Berger, Scott F. Kaplan, and J. Eliot B. Moss. 2004. Automatic Heap Sizing: Taking Real Memory into Account. In Proceedings of the 4th International Symposium on Memory Management (ISMM ’04). Association for Computing Machinery, New York, NY, USA. 61–72. isbn:1581139454 https://doi.org/10.1145/1029873.1029881 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Chengliang Zhang, Kirk Kelsey, Xipeng Shen, Chen Ding, Matthew Hertz, and Mitsunori Ogihara. 2006. Program-Level Adaptive Memory Management. In Proceedings of the 5th International Symposium on Memory Management (ISMM ’06). Association for Computing Machinery, New York, NY, USA. 174–183. isbn:1595932216 https://doi.org/10.1145/1133956.1133979 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Optimal heap limits for reducing browser memory use

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Article Metrics

        • Downloads (Last 12 months)425
        • Downloads (Last 6 weeks)34

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!