Skip to main content

Module scheduler

Module scheduler 

Source
Expand description

Deterministic event loop scheduler for PiJS runtime.

Implements the spec from EXTENSIONS.md §1A.4.5:

  • Queue model: microtasks (handled by JS engine), macrotasks, timers
  • Timer heap with stable ordering guarantees
  • Hostcall completion enqueue with stable tie-breaking
  • Single-threaded scheduler loop reproducible under fixed inputs

§Invariants

  • I1 (single macrotask): at most one macrotask executes per tick
  • I2 (microtask fixpoint): after any macrotask, microtasks drain to empty
  • I3 (stable timers): timers with equal deadlines fire in increasing seq order
  • I4 (no reentrancy): hostcall completions enqueue macrotasks, never re-enter
  • I5 (total order): all observable scheduling is ordered by seq

Structs§

DeterministicClock
A deterministic clock for testing.
HugepageConfig
Configuration for hugepage-backed slab allocation.
HugepageStatus
Hugepage availability snapshot from the host.
Macrotask
A macrotask in the queue.
NumaSlab
Per-NUMA-node slab with free-list recycling.
NumaSlabConfig
Configuration for a NUMA-local slab pool.
NumaSlabHandle
Handle returned on successful slab allocation.
NumaSlabNodeTelemetry
Per-node telemetry counters.
NumaSlabPool
Multi-node slab pool that routes allocations to NUMA-local slabs.
NumaSlabTelemetry
Aggregate slab pool telemetry.
ReactorBackpressure
Backpressure signal for rejected mesh enqueue operations.
ReactorEnvelope
Per-envelope metadata produced by ReactorMesh.
ReactorMesh
Deterministic multi-shard reactor mesh using bounded per-shard SPSC lanes.
ReactorMeshConfig
Configuration for ReactorMesh.
ReactorMeshTelemetry
Lightweight telemetry snapshot for mesh queueing behavior.
ReactorPlacementManifest
Machine-readable shard placement manifest.
ReactorShardBinding
Deterministic shard binding produced by placement planner.
ReactorTopologyCore
Core descriptor used by topology-aware shard placement.
ReactorTopologySnapshot
Lightweight machine-provided topology snapshot.
Scheduler
The deterministic event loop scheduler state.
Seq
Monotonically increasing sequence counter for deterministic ordering.
ThreadAffinityAdvice
Advisory thread-to-core binding produced from placement manifest.
TimerEntry
A timer entry in the timer heap.
WallClock
Real wall clock implementation.

Enums§

AffinityEnforcement
Enforcement level for thread-to-core affinity.
CrossNodeReason
Cross-node allocation reason for telemetry.
HostcallOutcome
Outcome of a hostcall.
HugepageFallbackReason
Reason why hugepage-backed allocation was not used.
MacrotaskKind
Type of macrotask in the queue.
ReactorPlacementFallbackReason
Explicit fallback reason emitted by topology planner.

Traits§

Clock
A monotonic clock source for the scheduler.