WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
296902
[libpas] bmalloc_heap.h should support aligned-zeroed allocations
https://bugs.webkit.org/show_bug.cgi?id=296902
Summary
[libpas] bmalloc_heap.h should support aligned-zeroed allocations
Marcus Plutowski
Reported
2025-08-04 15:55:12 PDT
rdar://157510912
Currently, we support both aligned allocations (e.g. bmalloc_allocate_with_alignment) and zeroed allocations (e.g. bmalloc_allocate_zeroed); however, we do not support simultaneously-aligned-and-zeroed allocations (e.g. bmalloc_allocate_zeroed_with_alignment). The consumer of the API can just zero it themselves, but libpas is careful to optimize out that zeroing operation if it knows it’s not necessary, e.g. if the page was newly mmap’d (c.f. pas_allocation_result_zero). This comes up when allocating wasm memory, as we basically 1. Ask for a huge allocation 2. Mmap over it to ensure it’s zero This is probably not itself a huge performance problem, but it does show up when I tried to switch that #2 over to madvise(MADV_ZERO): normally this would be preferable because this subsequent mmap would fragment the backing vm-objects (and acquire more locks), but in the case that we’re just replacing the entire vm-object anyways the first downside goes away, while the actual effort of going page-by-page and making sure they’re zeroed begins to dominate. Creating this new bmalloc_allocate_zeroed_with_alignment family of functions will allow us to avoid that unnecessary mmap and unblock migrating it to use madvise(MADV_ZERO) instead.
Attachments
Add attachment
proposed patch, testcase, etc.
Marcus Plutowski
Comment 1
2025-08-04 16:05:35 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/48928
EWS
Comment 2
2025-08-08 16:48:50 PDT
Committed
298428@main
(2ea1c1850d3a): <
https://commits.webkit.org/298428@main
> Reviewed commits have been landed. Closing PR #48928 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug