⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 173538 in webkit


Ignore:
Timestamp:
Sep 11, 2014, 1:58:02 PM (12 years ago)
Author:
ggaren@apple.com
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):

Location:
trunk/Source/bmalloc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r173525 r173538  
     12014-09-11  Geoffrey Garen  <ggaren@apple.com>
     2
     3        bmalloc should segregate medium-sized objects by line like it does for small-sized objects
     4        https://bugs.webkit.org/show_bug.cgi?id=136693
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        4% reduction in heap size on the MallocBench *_memory_warning benchmarks.
     9
     10        No throughput change.
     11
     12        We keep an array of medium allocators, just like our array of small
     13        allocators.
     14
     15        In future, we can simplify the allocation fast path by merging the small
     16        and medium allocator arrays. For now, this is the simplest change that
     17        gets the win.
     18
     19        * bmalloc/Allocator.cpp:
     20        (bmalloc::Allocator::Allocator):
     21        (bmalloc::Allocator::scavenge):
     22        (bmalloc::Allocator::allocateMedium):
     23        * bmalloc/Allocator.h:
     24        * bmalloc/Sizes.h:
     25        (bmalloc::Sizes::mediumSizeClassFor):
     26
    1272014-09-11  Geoffrey Garen  <ggaren@apple.com>
    228
  • trunk/Source/bmalloc/bmalloc/Allocator.cpp

    r173525 r173538  
    3939    : m_deallocator(deallocator)
    4040    , m_smallAllocators()
    41     , m_mediumAllocator()
     41    , m_mediumAllocators()
    4242    , m_smallAllocatorLog()
    4343    , m_mediumAllocatorLog()
    … …  
    5454    scavenge();
    5555}
    56    
     56
    5757void Allocator::scavenge()
    5858{
    … …  
    6363    processSmallAllocatorLog();
    6464
    65     retire(m_mediumAllocator);
    66     m_mediumAllocator.clear();
     65    for (auto& allocator : m_mediumAllocators) {
     66        retire(allocator);
     67        allocator.clear();
     68    }
    6769    processMediumAllocatorLog();
    6870}
    … …  
    130132void* Allocator::allocateMedium(size_t size)
    131133{
    132     MediumAllocator& allocator = m_mediumAllocator;
     134    MediumAllocator& allocator = m_mediumAllocators[mediumSizeClassFor(size)];
    133135    size = roundUpToMultipleOf<alignment>(size);
    134136
  • trunk/Source/bmalloc/bmalloc/Allocator.h

    r173525 r173538  
    6666
    6767    std::array<SmallAllocator, smallMax / alignment> m_smallAllocators;
    68     MediumAllocator m_mediumAllocator;
     68    std::array<MediumAllocator, mediumMax / alignment> m_mediumAllocators;
    6969
    7070    FixedVector<std::pair<SmallLine*, unsigned char>, smallAllocatorLogCapacity> m_smallAllocatorLog;
  • trunk/Source/bmalloc/bmalloc/Sizes.h

    r173224 r173538  
    7272    static_assert(1 << largeAlignmentShift == largeAlignment, "largeAlignmentShift be log2(largeAlignment).");
    7373    static const size_t largeMax = largeChunkSize * 99 / 100; // Plenty of room for metadata.
    74     static const size_t largeMin = 1024;
     74    static const size_t largeMin = mediumMax;
    7575
    7676    static const size_t segregatedFreeListSearchDepth = 16;
    … …  
    9898        return mask((size - 1ul) / alignment, smallSizeClassMask);
    9999    }
     100
     101    inline size_t mediumSizeClassFor(size_t size)
     102    {
     103        static const size_t mediumSizeClassMask = (mediumMax / alignment) - 1;
     104        return mask((size - 1ul) / alignment, mediumSizeClassMask);
     105    }
    100106};
    101107
Note: See TracChangeset for help on using the changeset viewer.