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

Changeset 201520 in webkit


Ignore:
Timestamp:
May 31, 2016, 12:45:10 PM (10 years ago)
Author:
sbarati@apple.com
Message:

Web Inspector: capturing with Allocations timeline causes GC to take 100x longer and cause frame drops
https://bugs.webkit.org/show_bug.cgi?id=158054
<rdar://problem/25280762>

Reviewed by Joseph Pecoraro.

HeapSnapshot::sweepCell was taking a long time on
http://bl.ocks.org/syntagmatic/6c149c08fc9cde682635
because it has to do a binary search to find if
an item is or is not in the list. 90% of the binary searches
would not find anything. This resulted in a lot of wasted time.

This patch adds a TinyBloomFilter member variable to HeapSnapshot.
We use this filter to try to bypass doing a binary search when the
filter tells us that a particular JSCell is definitely not in our
list. This is a 2x speedup on the steady state GC of the above
website.

  • heap/HeapSnapshot.cpp:

(JSC::HeapSnapshot::appendNode):
(JSC::HeapSnapshot::sweepCell):
(JSC::HeapSnapshot::shrinkToFit):
(JSC::HeapSnapshot::nodeForCell):

  • heap/HeapSnapshot.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r201495 r201520  
     12016-05-31  Saam Barati  <sbarati@apple.com>
     2
     3        Web Inspector: capturing with Allocations timeline causes GC to take 100x longer and cause frame drops
     4        https://bugs.webkit.org/show_bug.cgi?id=158054
     5        <rdar://problem/25280762>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        HeapSnapshot::sweepCell was taking a long time on
     10        http://bl.ocks.org/syntagmatic/6c149c08fc9cde682635
     11        because it has to do a binary search to find if
     12        an item is or is not in the list. 90% of the binary searches
     13        would not find anything. This resulted in a lot of wasted time.
     14
     15        This patch adds a TinyBloomFilter member variable to HeapSnapshot.
     16        We use this filter to try to bypass doing a binary search when the
     17        filter tells us that a particular JSCell is definitely not in our
     18        list. This is a 2x speedup on the steady state GC of the above
     19        website.
     20
     21        * heap/HeapSnapshot.cpp:
     22        (JSC::HeapSnapshot::appendNode):
     23        (JSC::HeapSnapshot::sweepCell):
     24        (JSC::HeapSnapshot::shrinkToFit):
     25        (JSC::HeapSnapshot::nodeForCell):
     26        * heap/HeapSnapshot.h:
     27
    1282016-05-29  Saam barati  <sbarati@apple.com>
    229
  • trunk/Source/JavaScriptCore/heap/HeapSnapshot.cpp

    r197489 r201520  
    4646
    4747    m_nodes.append(node);
     48    m_filter.add(bitwise_cast<uintptr_t>(node.cell));
    4849}
    4950
     
    5253    ASSERT(cell);
    5354
    54     if (m_finalized && !isEmpty()) {
     55    if (m_finalized && !m_filter.ruleOut(bitwise_cast<uintptr_t>(cell))) {
     56        ASSERT_WITH_MESSAGE(!isEmpty(), "Our filter should have ruled us out if we are empty.");
    5557        unsigned start = 0;
    5658        unsigned end = m_nodes.size();
     
    8082{
    8183    if (m_finalized && m_hasCellsToSweep) {
     84        m_filter.reset();
    8285        m_nodes.removeAllMatching(
    8386            [&] (const HeapSnapshotNode& node) -> bool {
    84                 return reinterpret_cast<intptr_t>(node.cell) & CellToSweepTag;
     87                bool willRemoveCell = bitwise_cast<intptr_t>(node.cell) & CellToSweepTag;
     88                if (!willRemoveCell)
     89                    m_filter.add(bitwise_cast<uintptr_t>(node.cell));
     90                return willRemoveCell;
    8591            });
    8692        m_nodes.shrinkToFit();
     
    127133    ASSERT(m_finalized);
    128134
    129     if (!isEmpty()) {
     135    if (!m_filter.ruleOut(bitwise_cast<uintptr_t>(cell))) {
     136        ASSERT_WITH_MESSAGE(!isEmpty(), "Our filter should have ruled us out if we are empty.");
    130137        unsigned start = 0;
    131138        unsigned end = m_nodes.size();
  • trunk/Source/JavaScriptCore/heap/HeapSnapshot.h

    r197489 r201520  
    2828
    2929#include "HeapSnapshotBuilder.h"
     30#include "TinyBloomFilter.h"
    3031#include <wtf/Optional.h>
    3132
     
    5455
    5556    Vector<HeapSnapshotNode> m_nodes;
     57    TinyBloomFilter m_filter;
    5658    HeapSnapshot* m_previous { nullptr };
    5759    unsigned m_firstObjectIdentifier { 0 };
Note: See TracChangeset for help on using the changeset viewer.