ReviewOS

zig-utils/zig-js

Runtime: account runnable and blocked engine threads

#981
Closed chris opened this 9 days ago ·
9 days ago

Parent: #502 Depends on: #978, #979, #980

Goal

Account for runnable and blocked engine-owned OS threads at the typed runtime boundary so shared CPU-slot admission can distinguish work consuming a core from work parked on a dependency.

Scope

  • Add nested, thread-local blocking scopes for every typed runtime thread.
  • Record current and peak runnable/blocked counts plus transition totals per resource kind in the coherent public snapshot.
  • Mark audited blocking paths for agents, shared-realm Threads, Workers, GC/GIL waits, and the execution watchdog.
  • Keep non-runtime host and test threads a zero-cost/no-op telemetry path.
  • Add deterministic concurrent and nested-transition tests under normal and TSan builds.
  • Update the versioned resource schema and inventory documentation.

Invariants

  • live = runnable + blocked for every coherent snapshot.
  • Each started runtime thread is runnable exactly once before its entry function and leaves exactly one state at completion.
  • Nested blocking scopes produce one outer blocked transition and one matching runnable transition.
  • No scheduling limit is enforced in this issue; #502 can only add shared slots after this accounting is complete.
9 days ago

Completed on main in 75a93eb. Every typed runtime thread now starts runnable, publishes nested blocked/runnable transitions around audited engine waits and joins, and must return to runnable before completion. The coherent public snapshot is schema v3 with current/peak runnable and blocked counts plus balanced transition totals; live = runnable + blocked. Validation: real agent, Worker, JavaScript Thread, and watchdog pressure paths under normal and TSan builds; 6/6 runtime audit with 142 reviewed test-only spawns; public/private ABI audits; 51-page docs build; and full units (2,499 passed, 1 skipped, 0 failed, 0 leaked). The test262 corpus was absent, so no conformance flip count is claimed.

Sign in to comment on this issue.