RESOLVED FIXED294583
[libpas] Use madvise(MADV_ZERO) instead of mmap for large zeroing operations
https://bugs.webkit.org/show_bug.cgi?id=294583
Summary [libpas] Use madvise(MADV_ZERO) instead of mmap for large zeroing operations
Marcus Plutowski
Reported 2025-06-16 15:01:36 PDT
rdar://153560968 When zeroing sufficiently large regions in libpas, we currently use mmap to make the OS give us new pages (instead of having to memset them ourselves). On Darwin, however, this approach is pessimizing in many cases (e.g. the page is still in lazy-zero-fill state, and so notionally could just be left in-place), and moreover causes issues with fragmentation inside the kernel that we want to avoid. The better alternative is to use madvise(p, sz, MADV_ZERO) whenever possible. This is not supported on Linux or older Darwin versions, so we will need to check for the presence of MADV_ZERO. Moreover, madvise can sometimes fail (e.g. for CoW pages), so we need to still support mmap as a fallback.
Attachments
Marcus Plutowski
Comment 1 2025-06-16 15:35:35 PDT
EWS
Comment 2 2025-06-17 09:29:49 PDT
Committed 296321@main (728128cdbd4f): <https://commits.webkit.org/296321@main> Reviewed commits have been landed. Closing PR #46824 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.