Title: [198545] trunk/Source/bmalloc
Revision
198545
Author
[email protected]
Date
2016-03-22 12:39:12 -0700 (Tue, 22 Mar 2016)

Log Message

bmalloc: shrink largeMax
https://bugs.webkit.org/show_bug.cgi?id=155759

Reviewed by Michael Saboff.

If a largeChunk contains N bytes and we allocate objects of size
N / 2 + 8 bytes, then we waste 50% of physical memory at peak.

This patch sets largeMax to N / 2, reducing maximum waste to 25%.

* bmalloc/BoundaryTag.h:
* bmalloc/LargeChunk.h:
(bmalloc::LargeChunk::LargeChunk):
* bmalloc/SegregatedFreeList.cpp:
(bmalloc::SegregatedFreeList::SegregatedFreeList):
(bmalloc::SegregatedFreeList::insert): Honor largeMax vs largeObjectMax.

* bmalloc/Sizes.h: Distinguish between the largest thing we can store
in a free list (largeObjectMax) and the largest thing we're willing to
allocate (largeMax).

Modified Paths

Diff

Modified: trunk/Source/bmalloc/ChangeLog (198544 => 198545)


--- trunk/Source/bmalloc/ChangeLog	2016-03-22 19:21:53 UTC (rev 198544)
+++ trunk/Source/bmalloc/ChangeLog	2016-03-22 19:39:12 UTC (rev 198545)
@@ -1,3 +1,26 @@
+2016-03-22  Geoffrey Garen  <[email protected]>
+
+        bmalloc: shrink largeMax
+        https://bugs.webkit.org/show_bug.cgi?id=155759
+
+        Reviewed by Michael Saboff.
+
+        If a largeChunk contains N bytes and we allocate objects of size
+        N / 2 + 8 bytes, then we waste 50% of physical memory at peak.
+
+        This patch sets largeMax to N / 2, reducing maximum waste to 25%.
+
+        * bmalloc/BoundaryTag.h:
+        * bmalloc/LargeChunk.h:
+        (bmalloc::LargeChunk::LargeChunk):
+        * bmalloc/SegregatedFreeList.cpp:
+        (bmalloc::SegregatedFreeList::SegregatedFreeList):
+        (bmalloc::SegregatedFreeList::insert): Honor largeMax vs largeObjectMax.
+
+        * bmalloc/Sizes.h: Distinguish between the largest thing we can store
+        in a free list (largeObjectMax) and the largest thing we're willing to
+        allocate (largeMax).
+
 2016-03-20  Dan Bernstein  <[email protected]>
 
         [Mac] Determine TARGET_MAC_OS_X_VERSION_MAJOR from MACOSX_DEPLOYMENT_TARGET rather than from MAC_OS_X_VERSION_MAJOR

Modified: trunk/Source/bmalloc/bmalloc/BoundaryTag.h (198544 => 198545)


--- trunk/Source/bmalloc/bmalloc/BoundaryTag.h	2016-03-22 19:21:53 UTC (rev 198544)
+++ trunk/Source/bmalloc/bmalloc/BoundaryTag.h	2016-03-22 19:39:12 UTC (rev 198545)
@@ -80,8 +80,8 @@
         "compactBegin must be encodable in a BoundaryTag.");
 
     static_assert(
-        (1 << sizeBits) - 1 >= largeMax,
-        "largeMax must be encodable in a BoundaryTag.");
+        (1 << sizeBits) - 1 >= largeObjectMax,
+        "largeObjectMax must be encodable in a BoundaryTag.");
 
     bool m_isFree: 1;
     bool m_isEnd: 1;

Modified: trunk/Source/bmalloc/bmalloc/LargeChunk.h (198544 => 198545)


--- trunk/Source/bmalloc/bmalloc/LargeChunk.h	2016-03-22 19:21:53 UTC (rev 198544)
+++ trunk/Source/bmalloc/bmalloc/LargeChunk.h	2016-03-22 19:39:12 UTC (rev 198545)
@@ -69,12 +69,12 @@
 };
 
 static_assert(largeChunkMetadataSize == sizeof(LargeChunk), "Our largeChunkMetadataSize math in Sizes.h is wrong");
-static_assert(largeChunkMetadataSize + largeMax == largeChunkSize, "largeMax is too small or too big");
+static_assert(largeChunkMetadataSize + largeObjectMax == largeChunkSize, "largeObjectMax is too small or too big");
 
 inline LargeChunk::LargeChunk()
 {
     Range range(begin(), end() - begin());
-    BASSERT(range.size() == largeMax);
+    BASSERT(range.size() == largeObjectMax);
 
     BeginTag* beginTag = LargeChunk::beginTag(range.begin());
     beginTag->setRange(range);

Modified: trunk/Source/bmalloc/bmalloc/SegregatedFreeList.cpp (198544 => 198545)


--- trunk/Source/bmalloc/bmalloc/SegregatedFreeList.cpp	2016-03-22 19:21:53 UTC (rev 198544)
+++ trunk/Source/bmalloc/bmalloc/SegregatedFreeList.cpp	2016-03-22 19:39:12 UTC (rev 198545)
@@ -30,7 +30,7 @@
 SegregatedFreeList::SegregatedFreeList(VMState::HasPhysical hasPhysical)
     : m_hasPhysical(hasPhysical)
 {
-    BASSERT(static_cast<size_t>(&select(largeMax) - m_freeLists.begin()) == m_freeLists.size() - 1);
+    BASSERT(static_cast<size_t>(&select(largeObjectMax) - m_freeLists.begin()) == m_freeLists.size() - 1);
 }
 
 void SegregatedFreeList::insert(const LargeObject& largeObject)

Modified: trunk/Source/bmalloc/bmalloc/Sizes.h (198544 => 198545)


--- trunk/Source/bmalloc/bmalloc/Sizes.h	2016-03-22 19:21:53 UTC (rev 198544)
+++ trunk/Source/bmalloc/bmalloc/Sizes.h	2016-03-22 19:39:12 UTC (rev 198545)
@@ -71,7 +71,8 @@
     static const size_t largeAlignment = 64;
     static const size_t largeMin = smallMax;
     static const size_t largeChunkMetadataSize = 4 * kB; // sizeof(LargeChunk)
-    static const size_t largeMax = largeChunkSize - largeChunkMetadataSize;
+    static const size_t largeObjectMax = largeChunkSize - largeChunkMetadataSize;
+    static const size_t largeMax = largeObjectMax / 2;
 
     static const size_t xLargeAlignment = superChunkSize;
     static const size_t xLargeMask = ~(xLargeAlignment - 1);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to