RESOLVED FIXED297151
[bmalloc] Re-enable use of madvise(MADV_ZERO) instead of mmap
https://bugs.webkit.org/show_bug.cgi?id=297151
Summary [bmalloc] Re-enable use of madvise(MADV_ZERO) instead of mmap
Marcus Plutowski
Reported 2025-08-08 16:35:08 PDT
rdar://155891567 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. The original patch (https://bugs.webkit.org/show_bug.cgi?id=295104) was reverted due to causing a performance loss. This loss goes away when we stop unnecessarily zeroing wasm memory, so it can now be relanded.
Attachments
Marcus Plutowski
Comment 1 2025-08-08 16:38:07 PDT
EWS
Comment 2 2025-08-08 21:52:49 PDT
Committed 298469@main (31fbeef33023): <https://commits.webkit.org/298469@main> Reviewed commits have been landed. Closing PR #49161 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.