state of multicore ocaml
play

State of Multicore OCaml KC Sivaramakrishnan University of OCaml - PowerPoint PPT Presentation

State of Multicore OCaml KC Sivaramakrishnan University of OCaml Labs Cambridge Outline Overview of the multicore OCaml project Multicore OCaml runtime design Future directions Multicore OCaml Multicore OCaml Add native


  1. State of Multicore OCaml KC Sivaramakrishnan University of OCaml Labs Cambridge

  2. Outline • Overview of the multicore OCaml project • Multicore OCaml runtime design • Future directions

  3. Multicore OCaml

  4. Multicore OCaml • Add native support for concurrency and (shared-memory) parallelism to OCaml

  5. Multicore OCaml • Add native support for concurrency and (shared-memory) parallelism to OCaml • History ★ Jan 2014: Initiated by Stephen Dolan and Leo White ★ Sep 2014: Multicore OCaml design @ OCaml workshop ★ Jan 2015: KC joins the project at OCaml Labs ★ Sep 2015: Effect handlers @ OCaml workshop ★ Jan 2016: Native code backend for Amd64 on Linux and OSX ★ Jun 2016: Multicore rebased to 4.02.2 from 4.00.0 ★ Sep 2016: Reagents library, Multicore backend for Links @ OCaml workshop ★ Apr 2017: ARM64 backend

  6. Multicore OCaml

  7. Multicore OCaml • History continued… ★ Jun 2017: Handlers for Concurrent System Programming @ TFP ★ Sep 2017: Memory model proposal @ OCaml workshop ★ Sep 2017: CPS translation for handlers @ FSCD ★ Apr 2018: Multicore rebased to 4.06.1 ( will track releases going forward ) ★ Jun 2018: Memory model @ PLDI

  8. Multicore OCaml • History continued… ★ Jun 2017: Handlers for Concurrent System Programming @ TFP ★ Sep 2017: Memory model proposal @ OCaml workshop ★ Sep 2017: CPS translation for handlers @ FSCD ★ Apr 2018: Multicore rebased to 4.06.1 ( will track releases going forward ) ★ Jun 2018: Memory model @ PLDI • Looking forward… ★ Q3’18 — Q4’18: Implement missing features, upstream prerequisites to trunk ★ Q1’19 — Q2’19: Submit feature-based PRs to upstream

  9. Components Multicore Runtime + Effect Handlers Effect System Domains

  10. Components Multicore Runtime + Effect Handlers Effect System Domains • Multicore Runtime ★ Multicore GC + Domains (creating and managing parallel threads)

  11. Components Multicore Runtime + Effect Handlers Effect System Domains • Multicore Runtime ★ Multicore GC + Domains (creating and managing parallel threads) • Effect handlers ★ Fibers: Runtime system support for linear delimited continuations

  12. Components Multicore Runtime + Effect Handlers Effect System Domains • Multicore Runtime ★ Multicore GC + Domains (creating and managing parallel threads) • Effect handlers ★ Fibers: Runtime system support for linear delimited continuations • Effect system ★ Track user-defined effects in the type system ★ Statically rule out the possibility of unhandled effects

  13. Components Multicore Runtime + Effect Handlers Effect System Domains • Multicore Runtime Current ★ Multicore GC + Domains (creating and managing parallel threads) implementation • Effect handlers ★ Fibers: Runtime system support for linear delimited continuations • Effect system ★ Track user-defined effects in the type system ★ Statically rule out the possibility of unhandled effects

  14. Components Multicore Runtime + Effect Handlers Effect System Domains • Multicore Runtime Work-in-progress Current ★ Multicore GC + Domains (creating and managing parallel threads) implementation • Effect handlers ★ Fibers: Runtime system support for linear delimited continuations • Effect system ★ Track user-defined effects in the type system ★ Statically rule out the possibility of unhandled effects

  15. Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  16. Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  17. Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 • Independent per-domain minor collection [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  18. ★ Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 • Independent per-domain minor collection Read barrier for mutable fields + promotion to major [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  19. ★ Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 • Independent per-domain minor collection Read barrier for mutable fields + promotion to major • A new major allocator based on StreamFlow [1], lock-free multithreaded allocation [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  20. ★ Multicore GC Major Heap Minor Minor Minor Minor Heap Heap Heap Heap Domain 0 Domain 1 Domain 2 Domain 3 • Independent per-domain minor collection Read barrier for mutable fields + promotion to major • A new major allocator based on StreamFlow [1], lock-free multithreaded allocation • A new major GC based on VCGC [2] adapted to fibers, ephemerons, finalisers [1] Scott Schneider, Christos D. Antonopoulos, and Dimitrios S. Nikolopoulos. "Scalable, locality-conscious multithreaded memory allocation." ISMM 2006. [2] Lorenz Huelsbergen and Phil Winterbottom. "Very concurrent mark-&-sweep garbage collection without fine-grain synchronization." ISMM 1998.

  21. Major GC • Concurrent, incremental, mark and sweep ★ Uses deletion/yuasa barrier ★ Upper bound on marking work per cycle (not fixed due to weak refs) • 3 phases: ★ Sweep-and-mark-main ★ Mark-final ★ Sweep-ephe

  22. Major GC: Sweep-and-mark-main

  23. Major GC: Sweep-and-mark-main Mark Domain 0 Roots Mark Domain 1 Roots • Domains begin by marking roots

  24. Major GC: Sweep-and-mark-main Mark Domain 0 Mutator Sweep Mutator Sweep Mutator Roots Mark Domain 1 Mutator Sweep Mutator Roots • Domains begin by marking roots • Domains alternate between sweeping own garbage and running mutator

  25. Major GC: Sweep-and-mark-main Mark Domain 0 Mutator Sweep Mutator Sweep Mutator Mark Mutator Mark Mutator Roots Mark Domain 1 Mutator Sweep Mutator Mark Mutator Mark Mutator Roots • Domains begin by marking roots • Domains alternate between sweeping own garbage and running mutator • Domains alternate between marking objects and running mutator

  26. Major GC: Sweep-and-mark-main Mark Domain 0 Mutator Sweep Mutator Sweep Mutator Mark Mutator Mark Mutator Roots Mark Domain 1 Mutator Sweep Mutator Mark Mutator Mark Mutator Roots • Domains begin by marking roots • Domains alternate between sweeping own garbage and running mutator • Domains alternate between marking objects and running mutator

  27. Major GC: Sweep-and-mark-main Mark Ephe Domain 0 Mutator Sweep Mutator Sweep Mutator Mark Mutator Mark Mutator Mutator Mark Mutator Roots Mark Mark Ephe Domain 1 Mutator Sweep Mutator Mark Mutator Mark Mutator Mutator Mark Mutator Roots Mark • Domains begin by marking roots • Domains alternate between sweeping own garbage and running mutator • Domains alternate between marking objects and running mutator • Domains alternate between marking ephemerons, marking other objects and running mutator

  28. Major GC: Sweep-and-mark-main Mark Ephe Domain 0 Mutator Sweep Mutator Sweep Mutator Mark Mutator Mark Mutator Mutator Mark Mutator Roots Mark Mark Ephe Domain 1 Mutator Sweep Mutator Mark Mutator Mark Mutator Mutator Mark Mutator Roots Mark • Domains begin by marking roots • Domains alternate between sweeping own garbage and running mutator • Domains alternate between marking objects and running mutator • Domains alternate between marking ephemerons, marking other objects and running mutator

Recommend


More recommend