Changeset 131388 in webkit


Ignore:
Timestamp:
Oct 15, 2012 5:36:39 PM (12 years ago)
Author:
kling@webkit.org
Message:

StyleResolver: Garbage collect the matched properties cache on a timer.
<http://webkit.org/b/98625>

Reviewed by Eric Seidel.

Sweeping the matched properties cache once every 100 additions ended up choking RoboHornet's
svgresize.html benchmark. Move it to a single-shot timer that's refreshed every 100 additions
and defers the actual sweep for 60 seconds.

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::sweepMatchedPropertiesCache):
(WebCore::StyleResolver::addToMatchedPropertiesCache):

  • css/StyleResolver.h:

(StyleResolver):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131387 r131388  
     12012-10-15  Andreas Kling  <kling@webkit.org>
     2
     3        StyleResolver: Garbage collect the matched properties cache on a timer.
     4        <http://webkit.org/b/98625>
     5
     6        Reviewed by Eric Seidel.
     7
     8        Sweeping the matched properties cache once every 100 additions ended up choking RoboHornet's
     9        svgresize.html benchmark. Move it to a single-shot timer that's refreshed every 100 additions
     10        and defers the actual sweep for 60 seconds.
     11
     12        * css/StyleResolver.cpp:
     13        (WebCore::StyleResolver::StyleResolver):
     14        (WebCore::StyleResolver::sweepMatchedPropertiesCache):
     15        (WebCore::StyleResolver::addToMatchedPropertiesCache):
     16        * css/StyleResolver.h:
     17        (StyleResolver):
     18
    1192012-10-15  Arnaud Renevier  <a.renevier@sisa.samsung.com>
    220
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r131357 r131388  
    265265    , m_backgroundData(BackgroundFillLayer)
    266266    , m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
     267    , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache)
    267268    , m_checker(document, !document->inQuirksMode())
    268269    , m_parentStyle(0)
     
    491492}
    492493
    493 void StyleResolver::sweepMatchedPropertiesCache()
     494void StyleResolver::sweepMatchedPropertiesCache(Timer<StyleResolver>*)
    494495{
    495496    // Look for cache entries containing a style declaration with a single ref and remove them.
    496     // This may happen when an element attribute mutation causes it to swap out its Attribute::decl()
    497     // for another CSSMappedAttributeDeclaration, potentially leaving this cache with the last ref.
     497    // This may happen when an element attribute mutation causes it to generate a new attributeStyle(),
     498    // potentially leaving this cache with the last ref on the old one.
    498499    Vector<unsigned, 16> toRemove;
    499500    MatchedPropertiesCache::iterator it = m_matchedPropertiesCache.begin();
     
    510511    for (size_t i = 0; i < toRemove.size(); ++i)
    511512        m_matchedPropertiesCache.remove(toRemove[i]);
     513
     514    m_matchedPropertiesCacheAdditionsSinceLastSweep = 0;
    512515}
    513516
     
    23782381void StyleResolver::addToMatchedPropertiesCache(const RenderStyle* style, const RenderStyle* parentStyle, unsigned hash, const MatchResult& matchResult)
    23792382{
    2380     static unsigned matchedDeclarationCacheAdditionsBetweenSweeps = 100;
     2383    static const unsigned matchedDeclarationCacheAdditionsBetweenSweeps = 100;
    23812384    if (++m_matchedPropertiesCacheAdditionsSinceLastSweep >= matchedDeclarationCacheAdditionsBetweenSweeps) {
    2382         sweepMatchedPropertiesCache();
    2383         m_matchedPropertiesCacheAdditionsSinceLastSweep = 0;
     2385        static const unsigned matchedDeclarationCacheSweepTimeInSeconds = 60;
     2386        m_matchedPropertiesCacheSweepTimer.startOneShot(matchedDeclarationCacheSweepTimeInSeconds);
    23842387    }
    23852388
  • trunk/Source/WebCore/css/StyleResolver.h

    r131047 r131388  
    430430    // Every N additions to the matched declaration cache trigger a sweep where entries holding
    431431    // the last reference to a style declaration are garbage collected.
    432     void sweepMatchedPropertiesCache();
     432    void sweepMatchedPropertiesCache(Timer<StyleResolver>*);
    433433
    434434    unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
     
    436436    typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
    437437    MatchedPropertiesCache m_matchedPropertiesCache;
     438
     439    Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer;
    438440
    439441    // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for
Note: See TracChangeset for help on using the changeset viewer.