Parent: #502 Related: #481, #480 Depends on: #983, #984
Goal
Coordinate the CPU cost of the existing synchronous JIT and WebAssembly compilers across typed engine threads and embedder host threads without introducing an asynchronous artifact queue that has no measured justification.
Current boundary
Baseline and optimizer compilation claim, compile, adopt, and publish synchronously at VM chunk entry. Stale optimizer generations and owner invalidation already reject publication. Wasm decode, validation, and compilation are likewise synchronous. Compilation requested by a typed JavaScript Thread already runs inside its runnable slot; compilation requested by an untyped embedder thread is outside scheduler accounting.
#481 permits background compilation only if measurement justifies it and artifact claims, teardown, no-GIL readers, W^X, memory pressure, and deterministic tests stay exact. Moving today's compiler async before that evidence would add a queue and cancellation lifetime with no existing queued work to manage.
Scope
- Add an owned compile-pressure benchmark with JIT-off execution controls and 1/2/4/host-width independent Context lanes. Measure cold/warm wall time, compile wall/CPU attribution, publications/rejections, configured stacks, scheduler wait, and peak RSS from a clean revision.
- Add process-wide internal-work classes for native JIT compilation and Wasm compilation.
- A typed runtime thread enters internal work without consuming a second CPU slot. An untyped host compiler registers against the scheduler's reserved host lane; concurrent host compilers beyond that reservation join the bounded background priority queue.
- Extend coherent telemetry with active/peak internal work, reserved-host-lane use, queued work, waits, starts, completions, and cancellations/rejections. The total-capacity invariant must include typed runnable threads and registered host work.
- Wrap the two production VM tier compilers and the production Wasm module compile boundary. Keep claim/compile/publication synchronous and preserve the exact owner/tier generation checks.
- Teardown/invalidation continues waiting for active synchronous claims; there is no stale queued artifact and therefore no synthetic cancellation path.
- Add deterministic normal/TSan tests for nested typed compilation, reserved host work, excess-host queueing, invalidation during compile, and teardown.
- Publish dated raw/report evidence only from a clean tracked revision after the runner and schema land separately.
Non-goals
Asynchronous/background compilation, speculative compiler helpers, changing tier thresholds, OS priority/affinity, and compile-result caching. Any later async queue belongs to #481 and must use the evidence from this issue.
Acceptance
- Concurrent host compilation cannot make total accounted CPU work exceed detected or explicit scheduler capacity.
- Typed compilation never double-counts its requesting runnable thread.
- No thread waits for capacity while holding an artifact-owner lock; stale claims still cannot publish.
- JIT-off controls separate Context/execution scaling from compile cost.
- Forced-off/forced-on tier differentials, artifact lifetime, focused normal/TSan, full units, threadfuzz, and docs/audits pass.
- Dated evidence states whether asynchronous compilation is justified; no queue is added if the data does not support it.