Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5b0cfbc518e523528c2b6b2d58e2333a7ed392e9
      
https://github.com/WebKit/WebKit/commit/5b0cfbc518e523528c2b6b2d58e2333a7ed392e9
  Author: Marcus Plutowski <[email protected]>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M Source/bmalloc/CMakeLists.txt
    M Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
    M Source/bmalloc/libpas/libpas.xcodeproj/project.pbxproj
    M Source/bmalloc/libpas/src/libpas/pas_bitfit_directory.h
    M Source/bmalloc/libpas/src/libpas/pas_bitfit_heap.c
    M Source/bmalloc/libpas/src/libpas/pas_cartesian_tree.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_atomic_ptr.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_bitfit_directory_ptr.h
    R Source/bmalloc/libpas/src/libpas/pas_compact_bitfit_global_directory_ptr.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_cartesian_tree_node_ptr.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_heap_ptr.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.c
    M Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.h
    M Source/bmalloc/libpas/src/libpas/pas_compact_ptr.h
    R Source/bmalloc/libpas/src/libpas/pas_compact_segregated_heap_ptr.h
    M 
Source/bmalloc/libpas/src/libpas/pas_compact_segregated_size_directory_ptr.h
    M Source/bmalloc/libpas/src/libpas/pas_config.h
    M 
Source/bmalloc/libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c
    M Source/bmalloc/libpas/src/libpas/pas_enumerator.c
    M Source/bmalloc/libpas/src/libpas/pas_fast_large_free_heap.c
    M Source/bmalloc/libpas/src/libpas/pas_heap.c
    M Source/bmalloc/libpas/src/libpas/pas_heap.h
    M Source/bmalloc/libpas/src/libpas/pas_immortal_heap.c
    M Source/bmalloc/libpas/src/libpas/pas_immortal_heap.h
    M Source/bmalloc/libpas/src/libpas/pas_report_crash_pgm_report.h
    M Source/bmalloc/libpas/src/libpas/pas_root.c
    M Source/bmalloc/libpas/src/libpas/pas_root.h
    M Source/bmalloc/libpas/src/libpas/pas_segregated_size_directory.c
    M Source/bmalloc/libpas/src/libpas/pas_segregated_size_directory.h
    M Source/bmalloc/libpas/src/test/CartesianTreeTests.cpp
    A Source/bmalloc/libpas/src/test/CompactHeapReservationTests.cpp
    M Source/bmalloc/libpas/src/test/EnumerationTests.cpp
    M Source/bmalloc/libpas/src/test/TestHarness.cpp

  Log Message:
  -----------
  [libpas] Support compact reservations >=128MiB
https://bugs.webkit.org/show_bug.cgi?id=325689
rdar://184153510

Reviewed by Dan Hecht.

This patch increases the total size of libpas' compact heap reservation
to 256MiB, split across two 'allocation fronts' (to borrow some xzmalloc
terminology). The bottom front (bumping upwards) allocates objects with
alignment constraints under 16B, and can extend up to 128MiB at most.
The top front (bumping down) can only allocate >=16B-aligned objects,
but can extend all the way up to 256MiB. These limits are set by the
size of our 3B compact pointer type, which (using the standard 8B
minalign) can address up to 1 << 24 << 3 = 128MiB.
The new PAS_DEFINE_OVERALIGNED_COMPACT_PTR decl creates a type which
instead can address up to 1 << 24 << 4 = 256MiB; it does this by only
addressing 16B-aligned objects, thus allowing it to make use of the
top front while still accomodating 3B-wide compact pointers.

256MiB v
       v
       v
       v
       v
128MiB v
       pas_compact_heap_reservation_top_bump

       pas_compact_heap_reservation_bump
       ^
  0MiB ^

Note that while the top-front grows downwards, overaligned-compact pointers
objects within it are still addressed from the *bottom* of the
reservation.

The motivation for this patch is that memory-usage in the compact
reservation has trended upwards over time (e.g. further expansion of
TZone usage, more pas_heaps, etc.), such that a small but increasing
minority of user processes with significant (>50GiB) of memory usage are
beginning to exhaust it. Increasing the reservation to 256MiB should
ensure that ~never happens -- at least not until RAM starts getting cheaper
again.

This solution avoids downsides that would be incurred by the alternatives:
  A) Increase the compact-pointer minalign to 16B across the board:
     this would increase the size of segregated exclusive views (among
     other types) from 24B to 32B, wasting 8B per 16K small page.
  B) Increase compact-pointer width to 4B for pointers to 8B-aligned
     objects: this would necessarily increase the width of view-pointers,
     which would increase the TLC size by several KiB, incurred per thread
  C) Split the compact pointer reservation into two fully separate
     reservations: this would constrict both to 128MiB, meaning that
     cases where the (more space-consuming) objects now allocated from the
     overaligned reservation would today hit 128MiB in usage would still
     crash in the new world, while the other reservation would remain
     almost empty.

* Source/bmalloc/libpas/src/libpas/pas_bitfit_directory.h:
* Source/bmalloc/libpas/src/libpas/pas_bitfit_heap.c:
(pas_bitfit_heap_create):
* Source/bmalloc/libpas/src/libpas/pas_cartesian_tree.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_atomic_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_bitfit_directory_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_cartesian_tree_node_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_heap_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.c:
(initialize_if_necessary):
(try_allocate_bottom):
(try_allocate_top):
(pas_compact_heap_reservation_try_allocate):
* Source/bmalloc/libpas/src/libpas/pas_compact_heap_reservation.h:
(pas_compact_heap_reservation_is_overaligned):
* Source/bmalloc/libpas/src/libpas/pas_compact_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_compact_segregated_size_directory_ptr.h:
* Source/bmalloc/libpas/src/libpas/pas_config.h:
* Source/bmalloc/libpas/src/libpas/pas_enumerate_initially_unaccounted_pages.c:
(pas_enumerate_initially_unaccounted_pages):
* Source/bmalloc/libpas/src/libpas/pas_enumerator.c:
(pas_enumerator_create):
* Source/bmalloc/libpas/src/libpas/pas_fast_large_free_heap.c:
(insert_node):
* Source/bmalloc/libpas/src/libpas/pas_heap.c:
(pas_heap_create):
* Source/bmalloc/libpas/src/libpas/pas_heap.h:
* Source/bmalloc/libpas/src/libpas/pas_immortal_heap.c:
(bump_is_ok):
(pas_immortal_heap_allocate_with_manual_alignment):
* Source/bmalloc/libpas/src/libpas/pas_immortal_heap.h:
* Source/bmalloc/libpas/src/libpas/pas_root.c:
(pas_root_construct):
* Source/bmalloc/libpas/src/libpas/pas_root.h:
* Source/bmalloc/libpas/src/libpas/pas_segregated_size_directory.c:
(pas_segregated_size_directory_create):
* Source/bmalloc/libpas/src/libpas/pas_segregated_size_directory.h:
* Source/bmalloc/libpas/src/test/CartesianTreeTests.cpp:
(std::testDriver):
* Source/bmalloc/libpas/libpas.xcodeproj/project.pbxproj:
* Source/bmalloc/libpas/src/test/TestHarness.cpp:
(main):
* Source/bmalloc/libpas/src/test/CompactHeapReservationTests.cpp: Added.
(std::offsetInReservation):
(std::checkInFront):
(std::checkFrontInvariants):
(std::testReservationSize):
(std::testTryAllocateSelectsFront):
(std::checkDirectory):
(std::testCoreObjectsLandInTheRightFront):
(addCompactHeapReservationTests):
* Source/bmalloc/CMakeLists.txt:
* Source/bmalloc/bmalloc.xcodeproj/project.pbxproj:
* Source/bmalloc/libpas/src/libpas/pas_compact_bitfit_global_directory_ptr.h: 
Removed.
* Source/bmalloc/libpas/src/libpas/pas_compact_segregated_heap_ptr.h: Removed.
* Source/bmalloc/libpas/src/libpas/pas_report_crash_pgm_report.h:
* Source/bmalloc/libpas/src/test/EnumerationTests.cpp:
(std::testEnumerationInvalidCompactHeapBump):
(std::recordedRangesCover):
(std::findHeapCallback):
(std::testEnumerationCopiesBothCompactHeapFronts):
(addEnumerationTests):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to