mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Three runtime changes that lower peak memory without changing behavior: - In programs with workers, process.stdout.write and process.stderr.write of a view into a SharedArrayBuffer read it through a 64 KiB buffer instead of copying the whole view first, so writing a 32 MB shared view no longer holds a second 32 MB. Programs without workers keep the direct write. - The one-slot string spare keeps freed blocks of 512 bytes to 1 MiB only. A larger block stayed resident until a string of about its size came along, which a program that replaces its input with an edited copy never does. - The main thread trims its arena when its event loop waits with nothing ready, once it has carved 16 MB more since its last trim, as a parking thread does: pages that hold only free blocks go back to the system while the program waits on its workers.