Bug 294583
| Summary: | [libpas] Use madvise(MADV_ZERO) instead of mmap for large zeroing operations | ||
|---|---|---|---|
| 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://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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Marcus Plutowski
Pull request: https://github.com/WebKit/WebKit/pull/46824
EWS
Committed 296321@main (728128cdbd4f): <https://commits.webkit.org/296321@main>
Reviewed commits have been landed. Closing PR #46824 and removing active labels.