Bug 297151
| Summary: | [bmalloc] Re-enable use of madvise(MADV_ZERO) instead of mmap | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Marcus Plutowski <marcus_plutowski> |
| Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Marcus Plutowski
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Marcus Plutowski
Pull request: https://github.com/WebKit/WebKit/pull/49161
EWS
Committed 298469@main (31fbeef33023): <https://commits.webkit.org/298469@main>
Reviewed commits have been landed. Closing PR #49161 and removing active labels.