Skip to content

ABI: implement VM GC, memory accounting, and idle scheduling #207

Description

@chrisbbreuer

Parent

Scope

Implement the nine shared pinned VM imports:

  • JSC__VM__blockBytesAllocated
  • JSC__VM__collectAsync
  • JSC__VM__externalMemorySize
  • JSC__VM__heapSize
  • JSC__VM__performOpportunisticallyScheduledTasks
  • JSC__VM__releaseWeakRefs
  • JSC__VM__reportExtraMemory
  • JSC__VM__runGC
  • JSC__VM__shrinkFootprint

Pinned source behavior

The Bun 4982b91e bodies are the executable contract: blockBytesAllocated includes extra memory, externalMemorySize stays distinct, synchronous and deferred collection preserve their different scheduling semantics, runGC returns the size after the last full collection, and opportunistic work treats until as a duration from monotonic now.

Acceptance criteria

  • VM identity and every counter are shared by sibling realms and isolated across foreign context groups.
  • zig-gc exposes the minimal race-safe live/committed/last-full-collection accounting needed by zig-js; changes land in the dependency repository as their own small commits before the zig-js integration update.
  • Reported external/extra memory uses checked or saturating accounting, is observable in the pinned counters, and cannot wrap on repeated reports.
  • Synchronous runGC performs a full quiescent collection and returns the post-collection size; the non-sync and collectAsync paths request/defer work without pretending an immediate synchronous sweep occurred.
  • releaseWeakRefs, shrinkFootprint, and opportunistic scheduling execute real runtime checkpoints; they are not no-op compatibility symbols.
  • Focused coverage includes arena and precise-GC modes, reachable/unreachable allocation, weak processing, extra/external accounting, sibling/foreign VMs, monotonic scheduling bounds, null inputs, repeated collection, and post-collection return values.
  • Home/Bun inventories, README/API evidence, and all parent trackers are regenerated from checked-in results; benchmark scores remain unchanged unless the runtime hot path is materially altered.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions