Parent: #459 Depends on: #461, #476, #478, #479
Goal
Reduce Thread, Worker, channel, shared-buffer, task, waiter, and join lifecycle overhead while preserving the distinct shared-realm and isolated-agent semantics.
Scope
- Attribute OS-thread creation, runtime/Interpreter setup, root publication, task dispatch, joins, asyncJoin, message serialization/copy/transfer, queue growth/drain, shared-buffer refcounts, wait/notify parking, worker module startup, close/terminate, and creator-owned cleanup.
- Add bounded reusable worker/thread runtime infrastructure only where public lifecycle identity, thread-local state, inspector targets, GC roots, termination, and teardown remain exact.
- Optimize SPSC/MPSC channel operations, queue cursors/capacity, structured clone buffers, shared backing lifetime, and park/wake paths with explicit ownership and memory ordering.
- Separate user-level lock contention from engine lifecycle cost and retain
.gil = trueas a semantic mode, not a performance workaround.
No-workaround rules
- No hidden pre-running JavaScript Thread, skipped OS/runtime lifecycle inside a timer, message drop/coalescing, unbounded queue/buffer pool, handle-affinity weakening, or hard terminate that bypasses cleanup.
Acceptance
- #460/#461 cover script/module Workers, shared Threads, messages, empty polls, transfer/SAB, wait/notify, sync/async joins, close, terminate, and repeated lifecycle.
- Retained changes reduce attributed lifecycle/queue/wait cost with bounded RSS and exact operation counts.
- Message caps, failure atomicity, ownership, inspector transport, finalizers, module graphs, GC roots, and creator-thread callbacks remain exact.
- Worker/Thread corpus, lifecycle fuzz, no-GIL, TSan, OOM/fault, and leak gates pass.
- Shared comparison warmup/timed boundaries remain documented and symmetric.
Foundation
#1/#40/#49 and the remaining profile targets in docs/threads/production-readiness.md.