mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-29 07:04:09 +08:00
Finished fiber stacks went back to a spare pool that the event loop unmapped whenever it was about to sleep. A server's loop sleeps between nearly every pair of requests, so each request that awaited mapped, faulted in and unmapped a fresh 512 KiB stack: on a Hono server mmap, munmap and the page faults were about a fifth of its CPU time. Spares now outlive short sleeps. At most once a second a sleep unmaps the spares that no fiber took since the previous trim, and a sleep longer than two seconds unmaps them all, so an idle program still returns the memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>