GHC's Runtime System
summary
GHC’s runtime is described concretely: codegen exposes registers R1..R10 and special registers like CurrentTSO, allocation uses an Hp/HpLimit bump-pointer nursery (example: a 5-word / 40‑byte allocation), stacks use chunked Sp/SpLim regions, and the storage manager requests 1MB megablocks then slices into ~4KB blocks (can reserve ~1TB address space). The GC is generational with remembered sets; thunks use blackholing to indirections (eager vs lazy); schedulers use capabilities/tasks and TSOs with run queues and work‑pushing. Tooling: ThreadSanitizer, rr+gdb, Valgrind, +RTS flags; code pointers: InfoTables.h, Storage.c, HeapStackCheck.cmm, GC.c, Linker.c, utils/genapply; bytecode VM is a 16‑bit stack machine.
AI-written summary · about
chapters (15)
- 0:00GHC runtime intro
- 1:12Runtime overview
- 5:16STG machine recap
- 14:24Chunked stack
- 25:15Heap and nursery
- 32:55Closure types
- 43:23Thunk allocation
- 57:15Break recap
- 58:01Storage manager
- 1:00:32Megablock allocator
- 1:08:23Heap checks & GC
- 1:10:39Green threading
- 1:18:27Thread scheduler
- 1:23:08GHCi linker
- 1:26:47Debugging tools
related talks
41mPinpointing memory leaks in production Haskell deployments
15mUsing MMTk Garbage Collection in GHC (Lightning Talk)
36mGHC Status Report
58mGHC Status Report
01h 24mWhat we have learned about memory profiling in the last 5 years
14mExecution domains in GHC/Haskell (Lightning Talk)
30mLightweight profiling with ghc-stack-profiler
26mghc-specter: a GHC plugin that inspects the GHC state on live
