Skip to content

[bmalloc] Use madvise(MADV_ZERO) instead of mmap to zero memory #47308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Achierius
Copy link
Contributor

@Achierius Achierius commented Jun 27, 2025

1747d6d

[bmalloc] Use madvise(MADV_ZERO) instead of mmap to zero memory
https://bugs.webkit.org/show_bug.cgi?id=295104
rdar://154496366

Reviewed by Yusuke Suzuki.

Using mmap is pessimizing; I previously fixed this for libpas,
but I didn't realize at the time that there's a parallel flow
in bmalloc. This change thus corresponds to 296321@main, which
solves the same issue but for libpas.

* Source/bmalloc/bmalloc.xcodeproj/project.pbxproj:
* Source/bmalloc/bmalloc/VMAllocate.cpp: Added.
(bmalloc::zeroFillLatchIfMadvZeroIsSupported):
(bmalloc::isMadvZeroSupported):
* Source/bmalloc/bmalloc/VMAllocate.h:
(bmalloc::vmZeroAndPurge):

Canonical link: https://commits.webkit.org/296771@main

8a9b018

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@Achierius Achierius requested a review from a team as a code owner June 27, 2025 17:32
@Achierius Achierius self-assigned this Jun 27, 2025
@Achierius Achierius added the bmalloc For bugs in bmalloc label Jun 27, 2025
@Achierius Achierius added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing merge-queue Applied to send a pull request to merge-queue and removed unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing labels Jun 28, 2025
https://bugs.webkit.org/show_bug.cgi?id=295104
rdar://154496366

Reviewed by Yusuke Suzuki.

Using mmap is pessimizing; I previously fixed this for libpas,
but I didn't realize at the time that there's a parallel flow
in bmalloc. This change thus corresponds to 296321@main, which
solves the same issue but for libpas.

* Source/bmalloc/bmalloc.xcodeproj/project.pbxproj:
* Source/bmalloc/bmalloc/VMAllocate.cpp: Added.
(bmalloc::zeroFillLatchIfMadvZeroIsSupported):
(bmalloc::isMadvZeroSupported):
* Source/bmalloc/bmalloc/VMAllocate.h:
(bmalloc::vmZeroAndPurge):

Canonical link: https://commits.webkit.org/296771@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/bmalloc-use-MADV_ZERO branch from 8a9b018 to 1747d6d Compare June 28, 2025 17:04
@webkit-commit-queue
Copy link
Collaborator

Committed 296771@main (1747d6d): https://commits.webkit.org/296771@main

Reviewed commits have been landed. Closing PR #47308 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 1747d6d into WebKit:main Jun 28, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bmalloc For bugs in bmalloc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants