Abstract
OCaml is an industrial-strength, multi-paradigm programming language, widely used in industry and academia. OCaml is also one of the few modern managed system programming languages to lack support for shared memory parallel programming. This paper describes the design, a full-fledged implementation and evaluation of a mostly-concurrent garbage collector (GC) for the multicore extension of the OCaml programming language. Given that we propose to add parallelism to a widely used programming language with millions of lines of existing code, we face the challenge of maintaining backwards compatibility--not just in terms of the language features but also the performance of single-threaded code running with the new GC. To this end, the paper presents a series of novel techniques and demonstrates that the new GC strikes a balance between performance and feature backwards compatibility for sequential programs and scales admirably on modern multicore processors.
Supplemental Material
- Todd A. Anderson. 2010. Optimizations in a Private Nursery-Based Garbage Collector. In Proceedings of the 2010 International Symposium on Memory Management (Toronto, Ontario, Canada) ( ISMM '10). Association for Computing Machinery, New York, NY, USA, 21-30. https://doi.org/10.1145/1806651.1806655 Google Scholar
Digital Library
- Andrew W Appel. 1990. A runtime system. Lisp and Symbolic Computation 3, 4 ( 1990 ), 343-380.Google Scholar
- Sven Auhagen, Lars Bergstrom, Matthew Fluet, and John Reppy. 2011. Garbage Collection for Multicore NUMA Machines. In Proceedings of the 2011 ACM SIGPLAN Workshop on Memory Systems Performance and Correctness (San Jose, California) ( MSPC '11). Association for Computing Machinery, New York, NY, USA, 51-57. https://doi.org/10.1145/1988915.1988929 Google Scholar
Digital Library
- François Bobot. 2014. Ephemerons meet OCaml GC. In OCaml Users and Developers Workshop.Google Scholar
- Sivaramakrishnan Krishnamoorthy Chandrasekaran, Daan Leijen, Matija Pretnar, and Tom Schrijvers. 2018. Algebraic Efect Handlers go Mainstream (Dagstuhl Seminar 18172). Dagstuhl Reports 8, 4 ( 2018 ), 104-125. https://doi.org/10.4230/ DagRep.8.4. 104 Google Scholar
Cross Ref
- Clif Click, Gil Tene, and Michael Wolf. 2005. The Pauseless GC Algorithm. In Proceedings of the 1st ACM/USENIX International Conference on Virtual Execution Environments (Chicago, IL, USA) ( VEE '05). Association for Computing Machinery, New York, NY, USA, 46-56. https://doi.org/10.1145/1064979.1064988 Google Scholar
Digital Library
- Edsger W Dijkstra, Leslie Lamport, Alain J. Martin, Carel S. Scholten, and Elisabeth FM Stefens. 1978. On-the-fly garbage collection: An exercise in cooperation. Commun. ACM 21, 11 ( 1978 ), 966-975.Google Scholar
- Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhavapeddy, KC Sivaramakrishnan, and Leo White. 2018a. Concurrent System Programming with Efect Handlers. In Trends in Functional Programming, Meng Wang and Scott Owens (Eds.). Springer International Publishing, Cham, 98-117.Google Scholar
- Stephen Dolan, KC Sivaramakrishnan, and Anil Madhavapeddy. 2018b. Bounding Data Races in Space and Time. In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation (Philadelphia, PA, USA) ( PLDI 2018 ). Association for Computing Machinery, New York, NY, USA, 242-255. https://doi.org/10.1145/ 3192366.3192421 Google Scholar
Digital Library
- Damien Doligez. 1989. Réalisation d'un glaneur de cellules de Lang et Dupont à générations. Memoire de DEA, Universite Paris VII ( 1989 ).Google Scholar
- Damien Doligez. 2019. A new allocator for OCaml. http://gallium.inria.fr/~scherer/doc/chameau-sur-le-plateau/2019-10-08-damien-doligez-major-allocator.orgGoogle Scholar
- Damien Doligez and Xavier Leroy. 1993. A Concurrent, Generational Garbage Collector for a Multithreaded Implementation of ML. In Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Charleston, South Carolina, USA) ( POPL '93). Association for Computing Machinery, New York, NY, USA, 113-123. https://doi.org/ 10.1145/158511.158611 Google Scholar
Digital Library
- Tamar Domani, Gal Goldshtein, Elliot K. Kolodner, Ethan Lewis, Erez Petrank, and Dafna Sheinwald. 2002. Thread-Local Heaps for Java. In Proceedings of the 3rd International Symposium on Memory Management (Berlin, Germany) ( ISMM '02). Association for Computing Machinery, New York, NY, USA, 76-87. https://doi.org/10.1145/512429.512439 Google Scholar
Digital Library
- Marc Feeley. 1993. Polling Eficiently on Stock Hardware. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture (Copenhagen, Denmark) ( FPCA '93). Association for Computing Machinery, New York, NY, USA, 179-187. https://doi.org/10.1145/165180.165205 Google Scholar
Digital Library
- Christine H. Flood, Roman Kennke, Andrew Dinn, Andrew Haley, and Roland Westrelin. 2016. Shenandoah: An Open-Source Concurrent Compacting Garbage Collector for OpenJDK. In Proceedings of the 13th International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (Lugano, Switzerland) ( PPPJ '16). Association for Computing Machinery, New York, NY, USA, Article 13, 9 pages. https://doi.org/10.1145/2972206.2972210 Google Scholar
Digital Library
- Matthew Fluet, Mike Rainey, John Reppy, and Adam Shaw. 2010. Implicitly Threaded Parallelism in Manticore. J. Funct. Program. 20, 5-6 ( Nov. 2010 ), 537-576. https://doi.org/10.1017/S0956796810000201 Google Scholar
Digital Library
- Ben Gamari and Laura Dietz. 2020. Alligator Collector: A Latency-Optimized Garbage Collector for Functional Programming Languages. In Proceedings of the 2020 ACM SIGPLAN International Symposium on Memory Management (London, UK) (ISMM 2020 ). Association for Computing Machinery, New York, NY, USA, 87âĂŞ99. https://doi.org/10.1145/3381898. 3397214 Google Scholar
Digital Library
- Peter Gammie, Antony L. Hosking, and Kai Engelhardt. 2015. Relaxing Safely: Verified on-the-Fly Garbage Collection for X86-TSO. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (Portland, OR, USA) ( PLDI '15). Association for Computing Machinery, New York, NY, USA, 99-109. https://doi.org/10. 1145/2737924.2738006 Google Scholar
Digital Library
- GoWriteBarrier 2015. Go Write Barrier. https://golang.org/src/runtime/mbarrier.goGoogle Scholar
- David Gries. 1977. An Exercise in Proving Parallel Programs Correct. Commun. ACM 20, 12 (Dec. 1977 ), 921-930. https://doi.org/10.1145/359897.359903 Google Scholar
Digital Library
- Adrien Guatto, Sam Westrick, Ram Raghunathan, Umut Acar, and Matthew Fluet. 2018. Hierarchical Memory Management for Mutable State. In Proceedings of the 23rd ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (Vienna, Austria) ( PPoPP '18). Association for Computing Machinery, New York, NY, USA, 81-93. https://doi.org/10. 1145/3178487.3178494 Google Scholar
Digital Library
- Barry Hayes. 1997. Ephemerons: A New Finalization Mechanism. In Proceedings of the 12th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (Atlanta, Georgia, USA) ( OOPSLA '97). Association for Computing Machinery, New York, NY, USA, 176-183. https://doi.org/10.1145/263698.263733 Google Scholar
Digital Library
- Gerard J. Holzmann. 1997. The Model Checker SPIN. IEEE Trans. Softw. Eng. 23, 5 (May 1997 ), 279-295. https://doi.org/10. 1109/32.588521 Google Scholar
Digital Library
- Lorenz Huelsbergen and Phil Winterbottom. 1998. Very Concurrent Mark-&-Sweep Garbage Collection without Fine-Grain Synchronization. In Proceedings of the 1st International Symposium on Memory Management (Vancouver, British Columbia, Canada) ( ISMM '98). Association for Computing Machinery, New York, NY, USA, 166-175. https://doi.org/10.1145/ 286860.286878 Google Scholar
Digital Library
- Richard Jones, Antony Hosking, and Eliot Moss. 2011. The Garbage Collection Handbook: The Art of Automatic Memory Management (1st ed.). Chapman & Hall/CRC.Google Scholar
- Xavier Leroy. 1990. The ZINC experiment : an economical implementation of the ML language. Technical Report RT-0117. INRIA. 100 pages. https://hal.inria.fr/inria-00070049Google Scholar
- Anil Madhavapeddy, Richard Mortier, Charalampos Rotsos, David Scott, Balraj Singh, Thomas Gazagnaire, Steven Smith, Steven Hand, and Jon Crowcroft. 2013. Unikernels: Library Operating Systems for the Cloud. In Proceedings of the Eighteenth International Conference on Architectural Support for Programming Languages and Operating Systems (Houston, Texas, USA) ( ASPLOS '13). Association for Computing Machinery, New York, NY, USA, 461-472. https://doi.org/10.1145/ 2451116.2451167 Google Scholar
Digital Library
- Simon Marlow and Simon Peyton Jones. 2011. Multicore Garbage Collection with Local Heaps. In Proceedings of the International Symposium on Memory Management (San Jose, California, USA) ( ISMM '11). Association for Computing Machinery, New York, NY, USA, 21-32. https://doi.org/10.1145/1993478.1993482 Google Scholar
Digital Library
- Simon Marlow, Simon Peyton Jones, and Satnam Singh. 2009. Runtime Support for Multicore Haskell. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (Edinburgh, Scotland) (ICFP '09). Association for Computing Machinery, New York, NY, USA, 65-78. https://doi.org/10.1145/1596550.1596563 Google Scholar
Digital Library
- Yaron Minsky, Anil Madhavapeddy, and Jason Hickey. 2013. Real World OCaml-Functional Programming for the Masses. O'Reilly. http://shop.oreilly.com/product/0636920024743.do#tab_04_2Google Scholar
- OCamlCAPI 2019. Interfacing C with OCaml. https://caml.inria.fr/pub/docs/manual-ocaml/intfc.htmlGoogle Scholar
- Ram Raghunathan, Stefan K. Muller, Umut A. Acar, and Guy Blelloch. 2016. Hierarchical Memory Management for Parallel Programs. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (Nara, Japan) (ICFP 2016 ). Association for Computing Machinery, New York, NY, USA, 392-406. https://doi.org/10.1145/2951913.2951935 Google Scholar
Digital Library
- ReasonML 2019. ReasonML : A new syntax and toolchain for OCaml. https://reasonml.github.io/Google Scholar
- John H. Reppy. 1993. Concurrent ML : Design, Application and Semantics. In Functional Programming, Concurrency, Simulation and Automated Reasoning: International Lecture Series 1991-1992, McMaster University, Hamilton, Ontario, Canada. Springer-Verlag, Berlin, Heidelberg, 165-198.Google Scholar
- Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. 2006. Scalable Locality-Conscious Multithreaded Memory Allocation. In Proceedings of the 5th International Symposium on Memory Management (Ottawa, Ontario, Canada) ( ISMM '06). Association for Computing Machinery, New York, NY, USA, 84-94. https://doi.org/10.1145/1133956.1133968 Google Scholar
Digital Library
- KC Sivaramakrishnan, Stephen Dolan, Leo White, Sadiq Jafer, Tom Kelly, Anmol Sahoo, Sudha Parimala, Atul Dhiman, and Anil Madhavapeddy. 2020. Retrofitting Parallelism onto OCaml. ArXiv abs/ 2004.11663 ( 2020 ). https://arxiv.org/abs/ 2004. 11663Google Scholar
- KC Sivaramakrishnan, Lukasz Ziarek, and Suresh Jagannathan. 2012. Eliminating Read Barriers through Procrastination and Cleanliness. In Proceedings of the 2012 International Symposium on Memory Management (Beijing, China) ( ISMM '12). Association for Computing Machinery, New York, NY, USA, 49-60. https://doi.org/10.1145/2258996.2259005 Google Scholar
Digital Library
- KC Sivaramakrishnan, Lukasz Ziarek, and Suresh Jagannathan. 2014. MultiMLton: A multicore-aware runtime for standard ML. J. Funct. Program. 24, 6 ( 2014 ), 613-674. https://doi.org/10.1017/S0956796814000161 Google Scholar
Cross Ref
- Daniel Dominic Sleator and Robert Endre Tarjan. 1985. Self-Adjusting Binary Search Trees. J. ACM 32, 3 ( July 1985 ), 652-686. https://doi.org/10.1145/3828.3835 Google Scholar
Digital Library
- Thomas A. Standish. 1980. Data Structure Techniques. Addison-Wesley Longman Publishing Co., Inc., USA.Google Scholar
- Guy Lewis Steele Jr. 1977. Data Representations in PDP-10 MacLISP. Technical Report. Massauchusetts Institute of Technology Cambridge Artificial Intelligence Laboratory.Google Scholar
- James Swaine, Kevin Tew, Peter Dinda, Robert Bruce Findler, and Matthew Flatt. 2010. Back to the Futures: Incremental Parallelization of Existing Sequential Runtime Systems. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (Reno/Tahoe, Nevada, USA) ( OOPSLA '10). Association for Computing Machinery, New York, NY, USA, 583-597. https://doi.org/10.1145/1869459.1869507 Google Scholar
Digital Library
- Gil Tene, Balaji Iyengar, and Michael Wolf. 2011. C4: The Continuously Concurrent Compacting Collector. SIGPLAN Not. 46, 11 ( June 2011 ), 79-88. https://doi.org/10.1145/2076022.1993491 Google Scholar
Digital Library
- Kevin Tew, James Swaine, Matthew Flatt, Robert Bruce Findler, and Peter Dinda [email protected]. 2011. Places: Adding Message-Passing Parallelism to Racket. In Proceedings of the 7th Symposium on Dynamic Languages (Portland, Oregon, USA) ( DLS '11). Association for Computing Machinery, New York, NY, USA, 85-96. https://doi.org/10.1145/ 2047849.2047860 Google Scholar
Digital Library
- Katsuhiro Ueno and Atsushi Ohori. 2016. A Fully Concurrent Garbage Collector for Functional Programs on Multicore Processors. SIGPLAN Not. 51, 9 (Sept. 2016 ), 421-433. https://doi.org/10.1145/3022670.2951944 Google Scholar
Digital Library
- Martin T Vechev, David F Bacon, Perry Cheng, and David Grove. 2005. Derivation and evaluation of concurrent collectors. In European Conference on Object-Oriented Programming. Springer, 577-601.Google Scholar
Digital Library
- Sam Westrick, Rohan Yadav, Matthew Fluet, and Umut A. Acar. 2019. Disentanglement in Nested-Parallel Programs. Proc. ACM Program. Lang. 4, POPL, Article 47 ( Dec. 2019 ), 32 pages. https://doi.org/10.1145/3371115 Google Scholar
Digital Library
- T. Yuasa. 1990. Real-Time Garbage Collection on General-Purpose Machines. J. Syst. Softw. 11, 3 (March 1990 ), 181-198. https://doi.org/10.1016/ 0164-1212 ( 90 ) 90084-Y Google Scholar
Digital Library
Index Terms
Retrofitting parallelism onto OCaml
Recommendations
Retrofitting effect handlers onto OCaml
PLDI 2021: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and ImplementationEffect handlers have been gathering momentum as a mechanism for modular programming with user-defined effects. Effect handlers allow for non-local control flow mechanisms such as generators, async/await, lightweight threads and coroutines to be ...
An on-the-fly mark and sweep garbage collector based on sliding views
Special Issue: Proceedings of the OOPSLA '03 conferenceWith concurrent and garbage collected languages like Java and C# becoming popular, the need for a suitable non-intrusive, efficient, and concurrent multiprocessor garbage collector has become acute. We propose a novel mark and sweep on-the-fly algorithm ...
Reducing pause time of conservative collectors
MSP 2002 and ISMM 2002This paper describes an incremental conservative garbage collector that significantly reduces pause time of an existing collector by Boehm et al. Like their collector, it is a true conservative collector that does not require compiler cooperation but ...






Comments