Changeset 195575 in webkit


Ignore:
Timestamp:
Jan 25, 2016 6:57:51 PM (8 years ago)
Author:
akling@apple.com
Message:

MarkedSpace should have more precise allocators.
<https://webkit.org/b/153448>
<rdar://problem/23897477>

Reviewed by Geoffrey Garen.

The four classes responsible for the bulk of MarkedBlock allocations today are:

  • FunctionCodeBlock (640 bytes)
  • UnlinkedFunctionCodeBlock (304 bytes)
  • FunctionExecutable (168 bytes)
  • UnlinkedFunctionExecutable (144 bytes)

Due to the size class distribution in MarkedSpace, we've been wasting quite a lot
of heap space on these objects. Our "precise" allocators allowed allocation sizes
in 16-byte increments up to 128 bytes, but after that point, we'd only allocate
in 256-byte size increments.

Thus each instance of those classes would waste space as follows:

  • FunctionCodeBlock (768-byte cell, 128 bytes wasted)
  • UnlinkedFunctionCodeBlock (512-byte cell, 208 bytes wasted)
  • FunctionExecutable(256-byte cell, 88 bytes wasted)
  • UnlinkedFunctionExecutable(256-byte cell, 112 bytes wasted)

This patch raises the limit for precise allocations from 128 to 768, allowing us
to allocate these objects with far better space efficiency.

The cost of this is 7kB worth of MarkedAllocators and 70 (~2x) more allocators to
iterate whenever we iterate all the allocators.

  • heap/MarkedSpace.h:
  • heap/MarkedSpace.cpp:

(JSC::MarkedSpace::MarkedSpace):
(JSC::MarkedSpace::resetAllocators):
(JSC::MarkedSpace::forEachAllocator):
(JSC::MarkedSpace::isPagedOut):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r195563 r195575  
     12016-01-25  Andreas Kling  <akling@apple.com>
     2
     3        MarkedSpace should have more precise allocators.
     4        <https://webkit.org/b/153448>
     5        <rdar://problem/23897477>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        The four classes responsible for the bulk of MarkedBlock allocations today are:
     10
     11            - FunctionCodeBlock (640 bytes)
     12            - UnlinkedFunctionCodeBlock (304 bytes)
     13            - FunctionExecutable (168 bytes)
     14            - UnlinkedFunctionExecutable (144 bytes)
     15
     16        Due to the size class distribution in MarkedSpace, we've been wasting quite a lot
     17        of heap space on these objects. Our "precise" allocators allowed allocation sizes
     18        in 16-byte increments up to 128 bytes, but after that point, we'd only allocate
     19        in 256-byte size increments.
     20
     21        Thus each instance of those classes would waste space as follows:
     22
     23            - FunctionCodeBlock (768-byte cell, 128 bytes wasted)
     24            - UnlinkedFunctionCodeBlock (512-byte cell, 208 bytes wasted)
     25            - FunctionExecutable(256-byte cell, 88 bytes wasted)
     26            - UnlinkedFunctionExecutable(256-byte cell, 112 bytes wasted)
     27
     28        This patch raises the limit for precise allocations from 128 to 768, allowing us
     29        to allocate these objects with far better space efficiency.
     30
     31        The cost of this is 7kB worth of MarkedAllocators and 70 (~2x) more allocators to
     32        iterate whenever we iterate all the allocators.
     33
     34        * heap/MarkedSpace.h:
     35        * heap/MarkedSpace.cpp:
     36        (JSC::MarkedSpace::MarkedSpace):
     37        (JSC::MarkedSpace::resetAllocators):
     38        (JSC::MarkedSpace::forEachAllocator):
     39        (JSC::MarkedSpace::isPagedOut):
     40
    1412016-01-25  Filip Pizlo  <fpizlo@apple.com>
    242
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.cpp

    r191849 r195575  
    6363    }
    6464
    65     for (size_t cellSize = impreciseStep; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
     65    for (size_t cellSize = impreciseStart; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
    6666        allocatorFor(cellSize).init(heap, this, cellSize, false);
    6767        destructorAllocatorFor(cellSize).init(heap, this, cellSize, true);
     
    110110    }
    111111
    112     for (size_t cellSize = impreciseStep; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
     112    for (size_t cellSize = impreciseStart; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
    113113        allocatorFor(cellSize).reset();
    114114        destructorAllocatorFor(cellSize).reset();
     
    155155    }
    156156
    157     for (size_t cellSize = impreciseStep; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
     157    for (size_t cellSize = impreciseStart; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
    158158        functor(allocatorFor(cellSize));
    159159        functor(destructorAllocatorFor(cellSize));
     
    192192    }
    193193
    194     for (size_t cellSize = impreciseStep; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
     194    for (size_t cellSize = impreciseStart; cellSize <= impreciseCutoff; cellSize += impreciseStep) {
    195195        if (allocatorFor(cellSize).isPagedOut(deadline)
    196196            || destructorAllocatorFor(cellSize).isPagedOut(deadline))
  • trunk/Source/JavaScriptCore/heap/MarkedSpace.h

    r191159 r195575  
    6868    WTF_MAKE_NONCOPYABLE(MarkedSpace);
    6969public:
    70     // [ 16 ... 128 ]
     70    // [ 16 ... 768 ]
    7171    static const size_t preciseStep = MarkedBlock::atomSize;
    72     static const size_t preciseCutoff = 128;
     72    static const size_t preciseCutoff = 768;
    7373    static const size_t preciseCount = preciseCutoff / preciseStep;
    7474
    75     // [ 256 ... blockSize/2 ]
    76     static const size_t impreciseStep = 2 * preciseCutoff;
     75    // [ 1024 ... blockSize/2 ]
     76    static const size_t impreciseStart = 1024;
     77    static const size_t impreciseStep = 256;
    7778    static const size_t impreciseCutoff = MarkedBlock::blockSize / 2;
    7879    static const size_t impreciseCount = impreciseCutoff / impreciseStep;
Note: See TracChangeset for help on using the changeset viewer.