Expand description
Generational garbage collector for the BHC Runtime System.
This crate implements the garbage collector for the General Heap region as specified in H26-SPEC Section 9: Memory Model. Key features:
- Generational collection - Young/old generation with different strategies
- Pinned region support - Objects that must not move (FFI, device IO)
- Write barriers - Track cross-generation references
- Incremental collection - Minimize pause times for Server Profile
§Architecture
The GC manages the General Heap, which contains boxed Haskell values. Objects may be moved during collection unless they are pinned.
+------------------+------------------+------------------+
| Nursery (G0) | Survivor (G1) | Old Gen (G2) |
+------------------+------------------+------------------+
| | | |
| Young objects | Promoted from | Long-lived |
| Bump alloc | G0 after 1 | objects |
| Frequent GC | survival | Rare major GC |
| | | |
+------------------+------------------+------------------+
+------------------+
| Pinned Region |
+------------------+
| |
| Non-moving |
| objects |
| (FFI, DMA) |
| |
+------------------+§Design Goals
- Low latency for Server Profile (bounded pause times)
- High throughput for batch processing
- Deterministic behavior for Numeric Profile (no GC in hot paths)
- Safe FFI interop through pinned allocations
Modules§
- incremental
- Incremental marking for bounded-pause GC.
Structs§
- Garbage
Collector - The garbage collector.
- GcConfig
- Configuration for the garbage collector.
- GcHandle
- Handle to a GC-managed object.
- GcPtr
- A wrapper around
NonNull<u8>that isSend + Sync. - GcStats
- Statistics from garbage collection.
- Header
Flags - Flags stored in the object header.
- Object
Header - Object header stored before each GC-managed object.
- Pause
Measurement - A single GC pause measurement.
- Pause
Stats - Statistics for GC pause times with recent history.
- Pause
Summary - Summary of pause statistics for reporting.
- RootSet
- Root set for garbage collection.
- Write
Barrier - Write barrier for tracking cross-generation references.
Enums§
- Collection
Kind - Kind of GC collection that caused a pause.
- Generation
- Generation identifier.