mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-12 02:13:04 +08:00
The trim helper returned parked workers' memory once no worker had run for 100 ms. A compiler in watch mode starts its workers again for each rebuild and faulted the returned pages back in, and a rebuild that runs on the main thread alone had the discards run alongside it. - The delay starts at 1 s (SCR_SA_DISCARD_DELAY_MS) and doubles each time workers start within ten delays of a discard, up to SCR_SA_DISCARD_DELAY_MAX_MS (10 s by default). - Once the event loop of the thread that is not a worker runs, the helper discards one arena at a time, and only while that loop has been in one wait with nothing ready for a step (scr_sa_loop_waiting, called by the event loop around its sleep). A loop that does not wait gets the discards SCR_SA_DISCARD_DELAY_MAX_MS after the delay. - Programs without a running event loop discard after the delay, as before.