How the Multicore Garbage Collector works
summary
OCaml 5 ships a multicore GC that keeps sequential performance by using a shared major heap plus per-domain minor heaps (minor default ~2MB) and bump-pointer allocation for fast allocs. Minor collections stop the world across domains and copy live objects to the major heap; the major GC is incremental mark-and-sweep with per-domain mark stacks and disjoint sweeping. Compaction runs in-place but is manual on multicore for now. Design builds on ICFP 2020 “Retrofitting Parallelism,” after ~7 years of work.
AI-written summary · about
chapters (18)
- 0:00Introduction to multicore GC
- 1:04History of multicore support
- 2:09GC trade-offs and memory layout
- 3:56Pointers and metadata in OCaml
- 5:24Generational heap in OCaml
- 6:48Key takeaways for OCaml programs
- 8:14Minor heap allocation and collection
- 11:43Minor GC collection process
- 13:25Multicore GC architecture
- 15:59Stop-the-world minor collection
- 17:25Major heap Mark and sweep
- 18:49Marking phase in major GC
- 21:44Sweeping phase in major GC
- 23:15Multicore major GC details
- 24:44Allocator and collector interaction
- 25:49Heap compaction in OCaml
- 26:33Final key takeaways
- 27:18Q&A session
