Title: [173538] trunk/Source/bmalloc
- Revision
- 173538
- Author
- [email protected]
- Date
- 2014-09-11 13:58:02 -0700 (Thu, 11 Sep 2014)
Log Message
bmalloc should segregate medium-sized objects by line like it does for small-sized objects
https://bugs.webkit.org/show_bug.cgi?id=136693
Reviewed by Gavin Barraclough.
4% reduction in heap size on the MallocBench *_memory_warning benchmarks.
No throughput change.
We keep an array of medium allocators, just like our array of small
allocators.
In future, we can simplify the allocation fast path by merging the small
and medium allocator arrays. For now, this is the simplest change that
gets the win.
* bmalloc/Allocator.cpp:
(bmalloc::Allocator::Allocator):
(bmalloc::Allocator::scavenge):
(bmalloc::Allocator::allocateMedium):
* bmalloc/Allocator.h:
* bmalloc/Sizes.h:
(bmalloc::Sizes::mediumSizeClassFor):
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (173537 => 173538)
--- trunk/Source/bmalloc/ChangeLog 2014-09-11 20:54:35 UTC (rev 173537)
+++ trunk/Source/bmalloc/ChangeLog 2014-09-11 20:58:02 UTC (rev 173538)
@@ -1,5 +1,31 @@
2014-09-11 Geoffrey Garen <[email protected]>
+ bmalloc should segregate medium-sized objects by line like it does for small-sized objects
+ https://bugs.webkit.org/show_bug.cgi?id=136693
+
+ Reviewed by Gavin Barraclough.
+
+ 4% reduction in heap size on the MallocBench *_memory_warning benchmarks.
+
+ No throughput change.
+
+ We keep an array of medium allocators, just like our array of small
+ allocators.
+
+ In future, we can simplify the allocation fast path by merging the small
+ and medium allocator arrays. For now, this is the simplest change that
+ gets the win.
+
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::Allocator):
+ (bmalloc::Allocator::scavenge):
+ (bmalloc::Allocator::allocateMedium):
+ * bmalloc/Allocator.h:
+ * bmalloc/Sizes.h:
+ (bmalloc::Sizes::mediumSizeClassFor):
+
+2014-09-11 Geoffrey Garen <[email protected]>
+
Reviewed by Sam Weinig.
Renamed log => retire for clarity.
Modified: trunk/Source/bmalloc/bmalloc/Allocator.cpp (173537 => 173538)
--- trunk/Source/bmalloc/bmalloc/Allocator.cpp 2014-09-11 20:54:35 UTC (rev 173537)
+++ trunk/Source/bmalloc/bmalloc/Allocator.cpp 2014-09-11 20:58:02 UTC (rev 173538)
@@ -38,7 +38,7 @@
Allocator::Allocator(Deallocator& deallocator)
: m_deallocator(deallocator)
, m_smallAllocators()
- , m_mediumAllocator()
+ , m_mediumAllocators()
, m_smallAllocatorLog()
, m_mediumAllocatorLog()
{
@@ -53,7 +53,7 @@
{
scavenge();
}
-
+
void Allocator::scavenge()
{
for (auto& allocator : m_smallAllocators) {
@@ -62,8 +62,10 @@
}
processSmallAllocatorLog();
- retire(m_mediumAllocator);
- m_mediumAllocator.clear();
+ for (auto& allocator : m_mediumAllocators) {
+ retire(allocator);
+ allocator.clear();
+ }
processMediumAllocatorLog();
}
@@ -129,7 +131,7 @@
void* Allocator::allocateMedium(size_t size)
{
- MediumAllocator& allocator = m_mediumAllocator;
+ MediumAllocator& allocator = m_mediumAllocators[mediumSizeClassFor(size)];
size = roundUpToMultipleOf<alignment>(size);
void* object;
Modified: trunk/Source/bmalloc/bmalloc/Allocator.h (173537 => 173538)
--- trunk/Source/bmalloc/bmalloc/Allocator.h 2014-09-11 20:54:35 UTC (rev 173537)
+++ trunk/Source/bmalloc/bmalloc/Allocator.h 2014-09-11 20:58:02 UTC (rev 173538)
@@ -65,7 +65,7 @@
Deallocator& m_deallocator;
std::array<SmallAllocator, smallMax / alignment> m_smallAllocators;
- MediumAllocator m_mediumAllocator;
+ std::array<MediumAllocator, mediumMax / alignment> m_mediumAllocators;
FixedVector<std::pair<SmallLine*, unsigned char>, smallAllocatorLogCapacity> m_smallAllocatorLog;
FixedVector<std::pair<MediumLine*, unsigned char>, mediumAllocatorLogCapacity> m_mediumAllocatorLog;
Modified: trunk/Source/bmalloc/bmalloc/Sizes.h (173537 => 173538)
--- trunk/Source/bmalloc/bmalloc/Sizes.h 2014-09-11 20:54:35 UTC (rev 173537)
+++ trunk/Source/bmalloc/bmalloc/Sizes.h 2014-09-11 20:58:02 UTC (rev 173538)
@@ -71,7 +71,7 @@
static const size_t largeAlignmentShift = 6;
static_assert(1 << largeAlignmentShift == largeAlignment, "largeAlignmentShift be log2(largeAlignment).");
static const size_t largeMax = largeChunkSize * 99 / 100; // Plenty of room for metadata.
- static const size_t largeMin = 1024;
+ static const size_t largeMin = mediumMax;
static const size_t segregatedFreeListSearchDepth = 16;
@@ -97,6 +97,12 @@
static const size_t smallSizeClassMask = (smallMax / alignment) - 1;
return mask((size - 1ul) / alignment, smallSizeClassMask);
}
+
+ inline size_t mediumSizeClassFor(size_t size)
+ {
+ static const size_t mediumSizeClassMask = (mediumMax / alignment) - 1;
+ return mask((size - 1ul) / alignment, mediumSizeClassMask);
+ }
};
using namespace Sizes;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes