Offload functions to worker threads with shared memory primitives for Node.js.

perf(worker): cache fn-per-id; sync fast-path for trivial args master

Two small savings on the worker's per-task hot path: 1. Cache the resolved moroutine function by id. Previously every task did id.slice() + imported.has() + registry.get() every call; now it's a single fnCache.get() after the first call per moroutine. Applies to both handleTask and task-arg resolution. 2. When a task's args contain no MessagePort and no task-args, skip Promise.all and synchronously map through deserializeArg. Avoids allocating N promises + awaiting Promise.all for tasks with primitive args (the common case). Eliminates ~3 map/string ops and N promise allocations per call after warmup. Small but measurable gain in dispatch throughput. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>


+27 -19
1 changed file