Skip to main content

Crate bhc_rts_gc

Crate bhc_rts_gc 

Source
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§

GarbageCollector
The garbage collector.
GcConfig
Configuration for the garbage collector.
GcHandle
Handle to a GC-managed object.
GcPtr
A wrapper around NonNull<u8> that is Send + Sync.
GcStats
Statistics from garbage collection.
HeaderFlags
Flags stored in the object header.
ObjectHeader
Object header stored before each GC-managed object.
PauseMeasurement
A single GC pause measurement.
PauseStats
Statistics for GC pause times with recent history.
PauseSummary
Summary of pause statistics for reporting.
RootSet
Root set for garbage collection.
WriteBarrier
Write barrier for tracking cross-generation references.

Enums§

CollectionKind
Kind of GC collection that caused a pause.
Generation
Generation identifier.