Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Thinking Inside the Box: Compartmentalized Garbage Collection

Published: 08 April 2016 Publication History

Abstract

The web browser is the “new desktop.” Not only do many users spend most of their time using the browser, the browser has also become host to rich and dynamic applications that were previously tailored to each individual operating system. The lingua franca of web scripting, JavaScript, was pivotal in this development.
Imagine that all desktop applications allocated memory from a single heap managed by the operating system. To reclaim memory upon application shutdown, all processes would then be garbage collected—not just the one being quit. While operating systems improved upon this approach long ago, this was how browsers managed memory until recently.
This article explores compartmentalized memory management, an approach tailored specifically to web browsers. The idea is to partition the JavaScript heap into compartments and allocate objects to compartments based on their origin. All objects in the same compartment reference each other direct, whereas cross-origin references go through wrapper objects.
We carefully evaluate our techniques using Mozilla’s Firefox browser—which now ships with our enhancements—and demonstrate the benefits of collecting each compartment independently. This simultaneously improves runtime performance (up to 36%) and reduces garbage collection pause times (up to 75%) as well as the memory footprint of the browser. In addition, enforcing the same-origin security policy becomes simple and efficient with compartments.

Supplementary Material

a9-wagner-apndx.pdf (wagner.zip)
Supplemental movie, appendix, image and software files for, Thinking Inside the Box: Compartmentalized Garbage Collection

References

[1]
Saleh E. Abdullahi and Graem A. Ringwood. 1998. Garbage collecting the Internet: A survey of distributed garbage collection. Computing Surveys 30, 330--373. http://doi.acm.org/10.1145/292469.292471.
[2]
Alexander Aiken, Manuel Fähndrich, and Raph Levien. 1995. Better static memory management: Improving region-based analysis of higher-order languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’95). ACM Press, New York, NY, 174--185.
[3]
A. W. Appel. 1989. Simple generational garbage collection and fast allocation. Software—Practice and Experience 19, 2, 171--183.
[4]
Apple. 2012. The WebKit Open Source Project. (2012). Retrieved February 29, 2016 from http://www.webkit.org/projects/javascript/index.html.
[5]
Katherine Barabash and Erez Petrank. 2010. Tracing garbage collection on highly parallel platforms. In Proceedings of the International Symposium on Memory Management (ISMM’10). ACM, New York, NY, 1--10.
[6]
David A. Barrett and Benjamin G. Zorn. 1993. Using lifetime predictors to improve memory allocation performance. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’93). ACM Press, New York, NY, 187--196.
[7]
David A. Barrett and Benjamin G. Zorn. 1995. Garbage collection using a dynamic threatening boundary. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’95). ACM Press, New York, NY, 301--314.
[8]
Emery D. Berger, Kathryn S. McKinley, Robert D. Blumofe, and Paul R. Wilson. 2000. Hoard: A scalable memory allocator for multithreaded applications. In Proceedings of the International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS IX). ACM Press, New York, NY, 117--128.
[9]
Emery D. Berger, Benjamin G. Zorn, and Kathryn S. McKinley. 2002. Reconsidering custom memory allocation. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’04). ACM Press, New York, NY, 1--12.
[10]
Stephen M. Blackburn, Richard Jones, Kathryn S. McKinley, and J. Eliot B. Moss. 2002. Beltway: Getting around garbage collection gridlock. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’02). ACM Press, New York, NY, 153--164.
[11]
Stephen M. Blackburn, Sharad Singhai, Matthew Hertz, Kathryn S. McKinely, and J. Eliot B. Moss. 2001. Pretenuring for Java. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’01). ACM Press, New York, NY, 342--352.
[12]
Guy E. Blelloch and Perry Cheng. 1999. On bounding time and space for multiprocessor garbage collection. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’99). ACM Press, New York, NY, 104--117.
[13]
Robert D. Blumofe and Charles E. Leiserson. 1999. Scheduling multithreaded computations by work stealing. Journal of the ACM 46, 5, 720--748.
[14]
Hans-J. Boehm, Russ Atkinson, and Michael Plass. 1995. Ropes: An alternative to strings. Software—Practice and Experience 25, 12, (December 1995), 1315--1330.
[15]
Perry Cheng and Guy E. Blelloch. 2001. A parallel, real-time garbage collector. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’01). ACM Press, New York, NY, 125--136.
[16]
Trishul M. Chilimbi and James R. Larus. 1998. Using generational garbage collection to implement cache-conscious data placement. In Proceedings of the International Symposium on Memory Management (ISMM’98). ACM, New York, NY, 37--48.
[17]
Tamar Domani, Gal Goldshtein, Elliot K. Kolodner, Ethan Lewis, Erez Petrank, and Dafna Sheinwald. 2002. Thread-local heaps for Java. In Proceedings of the International Symposium on Memory Management (ISMM’02). ACM Press, New York, NY, 76--87.
[18]
Patrick Dubroy and Ravin Balakrishnan. 2010. A study of tabbed browsing among Mozilla Firefox users. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems (CHI’10). ACM Press, New York, NY, 673--682.
[19]
Toshio Endo, Kenjiro Taura, and Akinori Yonezawa. 1997. A scalable mark-sweep garbage collector on large-scale shared-memory machines. In SC. ACM, New York, NY, 48.
[20]
Christine H. Flood, David Detlefs, Nir Shavit, and Xiaolan Zhang. 2001. Parallel garbage collection for shared memory multiprocessors. In Proceedings of the 2001 Symposium on Java Virtual Machine Research and Technology Symposium (JVM’01). USENIX Association, Berkeley, CA, 21--21. http://portal.acm.org/citation.cfm?id=1267847.1267868.
[21]
Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff, Jesse Ruderman, Edwin W. Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, and Michael Franz. 2009. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’09). ACM Press, New York, NY, 465--478.
[22]
Google. 2009. Introducing Google Chrome OS. Retrieved February 29, 2016 from http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html.
[23]
Google. 2012. Chrome V8 - Efficient Garbage Collection. (2012). Retrieved February 29, 2016 from https://developers.google.com/v8/design#garb_coll. Accessed 01/31/2013.
[24]
Dirk Grunwald, Benjamin Zorn, and Robert Henderson. 1993. Improving the cache locality of memory allocation. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’93). ACM Press, New York, NY, 177--186.
[25]
Samuel Z. Guyer and Kathryn S. McKinley. 2004. Finding your cronies: Static analysis for dynamic object colocation. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’04). ACM, New York, NY, 237--250. http://doi.acm.org/10.1145/1028976.1028996
[26]
Brian Hackett and Shu-yu Guo. 2012. Fast and precise hybrid type inference for JavaScript. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’12), Jan Vitek, Haibo Lin, and Frank Tip (Eds.). ACM Press, New York, NY, 239--250.
[27]
David R. Hanson. 1977. Storage management for an implementation of SNOBOL4. Software—Practice and Experience 7, 2, 179--192.
[28]
D. R. Hanson. 1990. Fast allocation and deallocation of memory based on object lifetimes. Software—Practice and Experience 20, 1, 5--12.
[29]
Barry Hayes. 1991. Using key object opportunism to collect old objects. In Conference Proceedings on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’91). ACM Press, New York, NY, 33--46.
[30]
Martin Hirzel, Johannes Henkel, Amer Diwan, and Michael Hind. 2002. Understanding the connectivity of heap objects. In Proceedings of the International Symposium on Memory Management (ISMM’02). ACM Press, New York, NY, 36--49.
[31]
Urs Hölzle, Craig Chambers, and David Ungar. 1991. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’91). Springer, Berlin.
[32]
Xianglong Huang, Stephen M. Blackburn, Kathryn S. McKinley, J. Eliot, B. Moss, Zhenlin Wang, and Perry Cheng. 2004. The garbage collection advantage: Improving program locality. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA’04), John M. Vlissides and Douglas C. Schmidt (Eds.). ACM Press, New York, NY, 69--80.
[33]
Richard L. Hudson and J. Eliot B. Moss. 1992. Incremental collection of mature objects. In Memory Management, Yves Bekkers and Jacques Cohen (Eds.). Lecture Notes in Computer Science, Vol. 637. Springer, Berlin, 388--403.
[34]
R. J. M. Hughes. 1982. A semi-incremental garbage collection algorithm. Software: Practice and Experience 12, 11, 1081--1082.
[35]
Intel. 1997. Using the RDTSC Instruction for Performance Monitoring. Retrieved February 29, 2016 from http://www.ccsl.carleton.ca/∼jamuir/rdtscpm1.pdf.
[36]
Mark Stuart Johnstone. 1997. Non-Compacting Memory Allocation and Real-Time Garbage Collection. Ph.D. Dissertation. University of Texas at Austin, Austin, TX. AAI9824978.
[37]
Mark S. Johnstone and Paul R. Wilson. 1998. The memory fragmentation problem: Solved? In Proceedings of the International Symposium on Memory Management (ISMM’98). ACM, New York, NY, 26--36.
[38]
Richard Jones, Anthony Hosking, and Eliot Moss. 2011. The Garbage Collection Handbook: The Art of Automatic Memory Management. Chapman and Hall/CRC & Sons, Inc., London, UK.
[39]
Eric Jul, Henry Levy, Norman Hutchinson, and Andrew Black. 1988. Fine-grained mobility in the Emerald system. ACM Transactions on Computer Systems 6, 1, 109--133.
[40]
Niels Christian Juul and Eric Jul. 1992. Comprehensive and robust garbage collection in a distributed system. In Proceedings of the International Symposium on Memory Management, Lecture Notes in Computer Science, Vol. 637. Springer, Berlin, 103--115.
[41]
Donald E. Knuth. 1973. The Art of Computer Programming, Fundamental Algorithms (2nd ed.). Vol. 1. Addison Wesley, Boston, MA.
[42]
Thomas Kotzmann, Christian Wimmer, Hanspeter Mössenböck, Thomas Rodriguez, Kenneth Russell, and David Cox. 2008. Design of the Java hotspot™ client compiler for Java 6. ACM Transactions on Architecture and Code Optimization 5, 1, 7:1--7:32.
[43]
B. Lang and F. Dupont. 1987. Incremental incrementally compacting garbage collection. In Papers of the Symposium on Interpreters and Interpretive Techniques (SIGPLAN’87). ACM, New York, NY, 253--263.
[44]
Jens Lindström. 2009. Carakan Revisited. Retrieved February 29, 2016 from https://dev.opera.com/blog/carakan-revisited/.
[45]
Linux Foundation. 2012. Tizen. Retrieved February 29, 2016 from https://www.tizen.org. Accessed 02/01/2013.
[46]
Andrew Miadowicz. 2012. Advances in JavaScript Performance in IE10 and Windows 8. Retrieved February 29, 2016 from http://blogs.msdn.com/b/ie/archive/2012/06/13/advances-in-javascript-performance-in-ie10-and-windows-8.aspx.
[47]
Microsoft. 2008. What’s New in Internet Explorer 8. Retrieved February 29, 2016 from http://msdn.microsoft.com/en-us/library/cc288472.aspxhttp://msdn.microsoft.com/en-us/library/cc288472spx.
[48]
Mozilla. 2011. Kraken JavaScript Benchmark. Retrieved February 29, 2016 from http://krakenbenchmark.mozilla.org/.
[49]
Mozilla. 2012. Experience Firefox OS on your Android device. Retrieved February 29, 2016 from http://www.mozilla.org/en-US/firefoxos/. Accessed 02/01/2013.
[50]
Oracle. 2010. Java 2 Platform SE v.1.4.2 API Specification. https://docs.oracle.com/javase/1.4.2/docs/api/. Accessed 01/28/2013.
[51]
Charles Reis and Steven D. Gribble. 2009. Isolating web programs in modern browser architectures. In Proceedings of the European Conference on Computer Systems. ACM Press, New York, NY, 219--232.
[52]
Jeffrey Richter. 2000. Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework. http://www.cs.inf.ethz.ch/37-201/files/GC_in_NET.pdf. Accessed 01/28/2013.
[53]
Douglas T. Ross. 1967. The AED free storage package. Communications of the ACM 10, 481--492. Issue 8.
[54]
J. Rudermann. 2001. The Same Origin Policy. Retrieved February 29, 2016 from https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript.
[55]
H. Schorr and W. M. Waite. 1967. An efficient machine-independent procedure for garbage collection in various list structures. Communications of the ACM 10, 8, 501--506.
[56]
Matthew L. Seidl and Benjamin G. Zorn. 1998. Segregating heap objects by reference behavior and lifetime. In Proceedings of the International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS-VIII). ACM Press, New York, NY, 12--23.
[57]
Yefim Shuf, Manish Gupta, Rajesh Bordawekar, and Jaswinder Pal Singh. 2002. Exploiting prolific types for memory management and optimizations. In Proceedings of the ACM SIGPLAN Symposium on Principles of Programming Languages (POPL’02). ACM Press, New York, NY, 295--306.
[58]
Fridtjof Siebert. 2000. Eliminating external fragmentation in a nonmoving garbage collector for Java. In Proceedings of the 2000 International Conference on Compilers, Architecture, and Synthesis for Embedded Systems (CASES’00). ACM, New York, NY, 9--17.
[59]
Fridtjof Siebert. 2008. Limits of parallel marking garbage collection. In Proceedings of the International Symposium on Memory Management (ISMM’08). ACM, New York, NY, 21--29.
[60]
Sunil Soman, Laurent Daynès, and Chandra Krintz. 2006. Task-aware garbage collection in a multi-tasking virtual machine. In Proceedings of the International Symposium on Memory Management (ISMM’06). ACM, New York, NY, 64--73.
[61]
Sunil Soman, Chandra Krintz, and Laurent Daynès. 2008. MTM2: Scalable memory management for multi-tasking managed runtime environments. In ECOOP 2008 -- Object-Oriented Programming, Jan Vitek (Ed.). Springer, Berlin, 335--361.
[62]
Steve Souders. 2013. HTTP Archive. (2013). Retrieved February 29, 2016 from http://httparchive.org/trends.php. Accessed 01/10/2013.
[63]
Bjarne Steensgaard. 2000. Thread-specific heaps for multi-threaded programs. In Proceedings of the International Symposium on Memory Management (ISMM’00). ACM, New York, NY, 18--24.
[64]
Mads Tofte. 1998. A brief introduction to regions. In Proceedings of the International Symposium on Memory Management (ISMM’98). ACM, New York, NY, 186--195. http://doi.acm.org/10.1145/286860.286882.
[65]
Mads Tofte and Jean-Pierre Talpin. 1997. Region-based memory management. Information and Computation 132, 2, 109--176.
[66]
David Ungar. 1984. Generation scavenging: A non-disruptive high performance storage reclamation algorithm. In Proceedings of the 1st ACM SIGSOFT/SIGPLAN Software Engineering Symposium on Practical Software Development Environments (SDE 1). ACM, New York, NY, 157--167.
[67]
Kiem-Phong Vo. 1996. Vmalloc: A general and efficient memory allocator. Software—Practice and Experience 26, 3, 357--374. CO;2-#
[68]
Gregor Wagner. 2011. Domain Specific Memory Management in a Modern Web Browser. Ph.D. Dissertation. Donald Bren School of Information and Computer Sciences, University of California, Irvine, Irvine, CA.
[69]
Gregor Wagner, Andreas Gal, Christian Wimmer, Brendan Eich, and Michael Franz. 2011. Compartmental memory management in a modern web browser. In Proceedings of the International Symposium on Memory Management (ISMM’11). ACM, New York, NY, 119--128.
[70]
Paul R. Wilson. 1992. Uniprocessor garbage collection techniques. In Proceedings of the International Workshop on Memory Management (IWMM'92). Springer-Verlag, London, UK, 1--42. http://dl.acm.org/citation.cfm?id=664824.
[71]
Paul R. Wilson, Michael S. Lam, and Thomas G. Moher. 1991. Effective “static-graph” reorganization to improve locality in garbage-collected systems. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’91). ACM Press, New York, NY, 177--191.
[72]
Benjamin G. Zorn. 1989. Comparative Performance Evaluation of Garbage Collection Algorithms. Ph.D. Dissertation. EECS Department, University of California, Berkeley, Berkeley, CA. http://www.eecs.berkeley.edu/Pubs/TechRpts/1989/5313.html.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Programming Languages and Systems
ACM Transactions on Programming Languages and Systems  Volume 38, Issue 3
May 2016
209 pages
ISSN:0164-0925
EISSN:1558-4593
DOI:10.1145/2914585
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 08 April 2016
Accepted: 01 December 2015
Revised: 01 June 2015
Received: 01 April 2013
Published in TOPLAS Volume 38, Issue 3

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Garbage collection
  2. isolation
  3. memory management
  4. web-browser architecture

Qualifiers

  • Research-article
  • Research
  • Refereed

Funding Sources

  • National Science Foundation
  • Defense Advanced Research Projects Agency (DARPA)

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 456
    Total Downloads
  • Downloads (Last 12 months)85
  • Downloads (Last 6 weeks)15
Reflects downloads up to 30 Aug 2024

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media