Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Flow and algorithm

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Algorithms for allocation, collection, and barrier execution. Architecture diagram: design model.

  1. Lowering emits alloc(size, type_descriptor_ptr) at object creation sites.
  2. Runtime enters current heap scope (enter_runtime_scope / TLS hooks).
  3. alloc delegates to Abfall allocate_beskid with descriptor metadata for scanning.
  4. On failure, runtime traps (panic) — no silent null returns for required objects.
  1. After each pointer store in generated code, lowering emits gc_write_barrier(parent, child).
  2. Barrier grays or marks child so concurrent marking retains reachability.
  3. Phase A may elide heavy barrier work when collector is idle, but the call site remains for ABI stability.
  1. Mutator allocation increases gc_bytes_allocated.
  2. gc_collect_if_needed compares growth against pacing policy (heap vs CPU tradeoff).
  3. When triggered, phases transition: idle → mark (STW root scan, concurrent mark) → mark termination STW → sweep.
  4. gc_phase export reports 0=Idle, 1=Marking, 2=Sweeping for tests and tooling.
  1. Implicit safepoints at calls and loop backedges (compiler-inserted).
  2. Stack maps at safepoints let STW scan precise roots.
  3. Fiber stack switching must register alternate stacks for enumeration (fiber scheduler).

Rust hosts call beskid_runtime::runtime::GcSnapshot instead of parsing raw gc_* exports when displaying heap stats or forcing collect.