mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-12 02:13:04 +08:00
On x86_64 and AArch64 POSIX targets, fiber switches now save and restore only the ABI's callee-saved state (scr_ctx_swap) instead of going through swapcontext/getcontext/makecontext. swapcontext saves and restores the process signal mask on every switch: one rt_sigprocmask syscall on glibc, and sigprocmask + sigaltstack + getrlimit on Darwin, plus a 16 KiB memset in Darwin's makecontext per spawn. Those dominated await-heavy programs (async-pipeline: most samples in sigprocmask/__sigaltstack/__getrlimit on macOS, 0.11 s of 0.23 s in the kernel on Linux). The runtime never uses a context to change the signal mask. Other POSIX targets keep ucontext; Windows and WASI are unchanged. The sanitizer fiber annotations wrap the new switch exactly as they wrapped swapcontext. The spare fiber-stack pool grows from 4 to 64 entries. With fan-out (Promise.all over a few batches) finished and new fibers alternate in waves wider than 4, so most spawns paid an mmap, a munmap, and fresh-page faults. Spares are still unmapped before the loop sleeps.