Skip to content

Bifurcate megapage caches into compact and non-compact variants #47384

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ddegazio
Copy link
Contributor

@ddegazio ddegazio commented Jun 30, 2025

2b72d76

Bifurcate megapage caches into compact and non-compact variants
https://bugs.webkit.org/show_bug.cgi?id=295062
rdar://154434088

Reviewed by NOBODY (OOPS!).

Adds new compact megapage caches to basic libpas heaps to support
separate heap management for compact pointers.

* Source/bmalloc/libpas/src/libpas/pas_basic_heap_page_caches.h:
* Source/bmalloc/libpas/src/libpas/pas_create_basic_heap_page_caches_with_reserved_memory.c:
(allocate_from_large):
(allocate_from_megapages):
(pas_create_basic_heap_page_caches_with_reserved_memory):
* Source/bmalloc/libpas/src/libpas/pas_heap_config_utils_inlines.h:
* Source/bmalloc/libpas/src/libpas/pas_megapage_cache.h:

2b72d76

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
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ❌ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@ddegazio ddegazio self-assigned this Jun 30, 2025
@ddegazio ddegazio requested a review from a team as a code owner June 30, 2025 18:48
@ddegazio ddegazio added the bmalloc For bugs in bmalloc label Jun 30, 2025
https://bugs.webkit.org/show_bug.cgi?id=295062
rdar://154434088

Reviewed by NOBODY (OOPS!).

Adds new compact megapage caches to basic libpas heaps to support
separate heap management for compact pointers.

* Source/bmalloc/libpas/src/libpas/pas_basic_heap_page_caches.h:
* Source/bmalloc/libpas/src/libpas/pas_create_basic_heap_page_caches_with_reserved_memory.c:
(allocate_from_large):
(allocate_from_megapages):
(pas_create_basic_heap_page_caches_with_reserved_memory):
* Source/bmalloc/libpas/src/libpas/pas_heap_config_utils_inlines.h:
* Source/bmalloc/libpas/src/libpas/pas_megapage_cache.h:
@ddegazio ddegazio force-pushed the eng/Bifurcate-megapage-caches-into-compact-and-non-compact-variants branch from ac8b9b0 to 2b72d76 Compare June 30, 2025 18:53
Comment on lines +137 to +150
pas_megapage_cache_construct(
&caches->small_compact_exclusive_segregated_megapage_cache,
allocate_from_large,
pas_megapage_cache_size_small_compact);

pas_megapage_cache_construct(
&caches->small_compact_other_megapage_cache,
allocate_from_large,
pas_megapage_cache_size_small_compact);

pas_megapage_cache_construct(
&caches->medium_compact_megapage_cache,
allocate_from_large,
pas_megapage_cache_size_medium_compact);
Copy link
Contributor

@Achierius Achierius Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that we need to allocate 32MiB for each of these (if I'm understanding correctly).
To some extent that doesn't matter since it's all VA, but some amount of that is faulted in -- does this show up at all on memory benchmarks?

Comment on lines +137 to +145
pas_megapage_cache_construct(
&caches->small_compact_exclusive_segregated_megapage_cache,
allocate_from_large,
pas_megapage_cache_size_small_compact);

pas_megapage_cache_construct(
&caches->small_compact_other_megapage_cache,
allocate_from_large,
pas_megapage_cache_size_small_compact);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these strictly need to be separate for functional reasons, or is it just for clarity's sake? I'm OK with "for clarity's sake" I just want to understand if the code would break sans this.

@@ -37,6 +37,29 @@
#include "pas_reserved_memory_provider.h"
#include "pas_segregated_shared_page_directory.h"

static pas_allocation_result allocate_from_large(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what's going on here. Why does the "allocate_from_megapages" now allocate from the megapage_large_heap, and this function now do what it was doing beforehand?

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.

3 participants