Title: [131388] trunk/Source/WebCore
Revision
131388
Author
[email protected]
Date
2012-10-15 17:36:39 -0700 (Mon, 15 Oct 2012)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131387 => 131388)


--- trunk/Source/WebCore/ChangeLog	2012-10-16 00:35:17 UTC (rev 131387)
+++ trunk/Source/WebCore/ChangeLog	2012-10-16 00:36:39 UTC (rev 131388)
@@ -1,3 +1,21 @@
+2012-10-15  Andreas Kling  <[email protected]>
+
+        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):
+
 2012-10-15  Arnaud Renevier  <[email protected]>
 
         [GStreamer] GstCaps are leaked when building with gstreamer-1.0

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (131387 => 131388)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-10-16 00:35:17 UTC (rev 131387)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-10-16 00:36:39 UTC (rev 131388)
@@ -264,6 +264,7 @@
     : m_hasUAAppearance(false)
     , m_backgroundData(BackgroundFillLayer)
     , m_matchedPropertiesCacheAdditionsSinceLastSweep(0)
+    , m_matchedPropertiesCacheSweepTimer(this, &StyleResolver::sweepMatchedPropertiesCache)
     , m_checker(document, !document->inQuirksMode())
     , m_parentStyle(0)
     , m_rootElementStyle(0)
@@ -490,11 +491,11 @@
     m_fontSelector->clearDocument();
 }
 
-void StyleResolver::sweepMatchedPropertiesCache()
+void StyleResolver::sweepMatchedPropertiesCache(Timer<StyleResolver>*)
 {
     // Look for cache entries containing a style declaration with a single ref and remove them.
-    // This may happen when an element attribute mutation causes it to swap out its Attribute::decl()
-    // for another CSSMappedAttributeDeclaration, potentially leaving this cache with the last ref.
+    // This may happen when an element attribute mutation causes it to generate a new attributeStyle(),
+    // potentially leaving this cache with the last ref on the old one.
     Vector<unsigned, 16> toRemove;
     MatchedPropertiesCache::iterator it = m_matchedPropertiesCache.begin();
     MatchedPropertiesCache::iterator end = m_matchedPropertiesCache.end();
@@ -509,6 +510,8 @@
     }
     for (size_t i = 0; i < toRemove.size(); ++i)
         m_matchedPropertiesCache.remove(toRemove[i]);
+
+    m_matchedPropertiesCacheAdditionsSinceLastSweep = 0;
 }
 
 static StyleSheetContents* parseUASheet(const String& str)
@@ -2377,10 +2380,10 @@
 
 void StyleResolver::addToMatchedPropertiesCache(const RenderStyle* style, const RenderStyle* parentStyle, unsigned hash, const MatchResult& matchResult)
 {
-    static unsigned matchedDeclarationCacheAdditionsBetweenSweeps = 100;
+    static const unsigned matchedDeclarationCacheAdditionsBetweenSweeps = 100;
     if (++m_matchedPropertiesCacheAdditionsSinceLastSweep >= matchedDeclarationCacheAdditionsBetweenSweeps) {
-        sweepMatchedPropertiesCache();
-        m_matchedPropertiesCacheAdditionsSinceLastSweep = 0;
+        static const unsigned matchedDeclarationCacheSweepTimeInSeconds = 60;
+        m_matchedPropertiesCacheSweepTimer.startOneShot(matchedDeclarationCacheSweepTimeInSeconds);
     }
 
     ASSERT(hash);

Modified: trunk/Source/WebCore/css/StyleResolver.h (131387 => 131388)


--- trunk/Source/WebCore/css/StyleResolver.h	2012-10-16 00:35:17 UTC (rev 131387)
+++ trunk/Source/WebCore/css/StyleResolver.h	2012-10-16 00:36:39 UTC (rev 131388)
@@ -429,13 +429,15 @@
 
     // Every N additions to the matched declaration cache trigger a sweep where entries holding
     // the last reference to a style declaration are garbage collected.
-    void sweepMatchedPropertiesCache();
+    void sweepMatchedPropertiesCache(Timer<StyleResolver>*);
 
     unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
 
     typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
     MatchedPropertiesCache m_matchedPropertiesCache;
 
+    Timer<StyleResolver> m_matchedPropertiesCacheSweepTimer;
+
     // A buffer used to hold the set of matched rules for an element, and a temporary buffer used for
     // merge sorting.
     Vector<const RuleData*, 32> m_matchedRules;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to