mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
First touch of fresh memory costs the allocating thread a page fault and a page clear. Linux executables now hand that to a helper thread: - Size-class slices raise their bump limits in steps (256 KiB on the small-page prefix, half a huge page after the switch), and each step asks the helper to fault in the next step ahead with MADV_POPULATE_WRITE, which commits zeroed pages without storing, so it cannot race with carving. A slice holds at most about one step of untouched committed memory; a slice's first chunk is not faulted ahead. - glibc's heap gets a 16 MiB top pad and the helper faults in each brk extension as soon as it sees the break move (checked after every request, then polled every 1 ms while it keeps growing; an idle program does not wake it). The fast paths are unchanged; pages the helper has not reached are still faulted by the owner. The helper masks all signals. SCR_SA_PREFAULT=0 turns it off, SCR_SA_PREFAULT_HEAP=0 keeps glibc's heap defaults; kernels without MADV_POPULATE_WRITE (< 5.14) fall back to the old policy, and library archives keep it. The slice-growth allocator check now carves past several huge-page steps and checks every fresh block reads as zero (UBSan and TSan builds run with the helper).