Title: [94340] trunk/Source/WebKit2
Revision
94340
Author
[email protected]
Date
2011-09-01 13:39:46 -0700 (Thu, 01 Sep 2011)

Log Message

Gather memory cache statistics in WebProcess::getWebCoreStatistics().
https://bugs.webkit.org/show_bug.cgi?id=67160

Reviewed by Darin Adler.

Encode and decode webCoreCacheStatistics data member in StatisticsData.
* Shared/StatisticsData.cpp:
(WebKit::StatisticsData::encode):
(WebKit::StatisticsData::decode):
* Shared/StatisticsData.h:

Convert the cache statistics data into an ImmutableArray and return it in WebContext::didGetWebCoreStatistics().
* UIProcess/WebContext.cpp:
(WebKit::WebContext::didGetWebCoreStatistics):

Store memory cache statistics into the StatisticsData object.
* WebProcess/WebProcess.cpp:
(WebKit::getWebCoreMemoryCacheStatistics):
(WebKit::WebProcess::getWebCoreStatistics):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (94339 => 94340)


--- trunk/Source/WebKit2/ChangeLog	2011-09-01 20:38:22 UTC (rev 94339)
+++ trunk/Source/WebKit2/ChangeLog	2011-09-01 20:39:46 UTC (rev 94340)
@@ -1,3 +1,25 @@
+2011-09-01  Ada Chan  <[email protected]>
+
+        Gather memory cache statistics in WebProcess::getWebCoreStatistics().
+        https://bugs.webkit.org/show_bug.cgi?id=67160
+
+        Reviewed by Darin Adler.
+
+        Encode and decode webCoreCacheStatistics data member in StatisticsData.
+        * Shared/StatisticsData.cpp:
+        (WebKit::StatisticsData::encode):
+        (WebKit::StatisticsData::decode):
+        * Shared/StatisticsData.h:
+
+        Convert the cache statistics data into an ImmutableArray and return it in WebContext::didGetWebCoreStatistics().
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::didGetWebCoreStatistics):
+
+        Store memory cache statistics into the StatisticsData object.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::getWebCoreMemoryCacheStatistics):
+        (WebKit::WebProcess::getWebCoreStatistics):
+
 2011-09-01  Tim Horton  <[email protected]>
 
         REGRESSION: Rendering artifacts on a rotated, pattern filled shape

Modified: trunk/Source/WebKit2/Shared/StatisticsData.cpp (94339 => 94340)


--- trunk/Source/WebKit2/Shared/StatisticsData.cpp	2011-09-01 20:38:22 UTC (rev 94339)
+++ trunk/Source/WebKit2/Shared/StatisticsData.cpp	2011-09-01 20:39:46 UTC (rev 94340)
@@ -35,6 +35,7 @@
     encoder->encode(statisticsNumbers);
     encoder->encode(_javascript_ProtectedObjectTypeCounts);
     encoder->encode(_javascript_ObjectTypeCounts);
+    encoder->encode(webCoreCacheStatistics);
 }
 
 bool StatisticsData::decode(CoreIPC::ArgumentDecoder* decoder, StatisticsData& statisticsData)
@@ -45,6 +46,8 @@
         return false;
     if (!decoder->decode(statisticsData._javascript_ObjectTypeCounts))
         return false;
+    if (!decoder->decode(statisticsData.webCoreCacheStatistics))
+        return false;
 
     return true;
 }

Modified: trunk/Source/WebKit2/Shared/StatisticsData.h (94339 => 94340)


--- trunk/Source/WebKit2/Shared/StatisticsData.h	2011-09-01 20:38:22 UTC (rev 94339)
+++ trunk/Source/WebKit2/Shared/StatisticsData.h	2011-09-01 20:39:46 UTC (rev 94340)
@@ -29,6 +29,7 @@
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
 #include <wtf/HashMap.h>
+#include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
 
@@ -41,6 +42,7 @@
     HashMap<String, uint64_t> statisticsNumbers;
     HashMap<String, uint64_t> _javascript_ProtectedObjectTypeCounts;
     HashMap<String, uint64_t> _javascript_ObjectTypeCounts;    
+    Vector<HashMap<String, uint64_t> > webCoreCacheStatistics;
     
     StatisticsData();
 };

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (94339 => 94340)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-09-01 20:38:22 UTC (rev 94339)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-09-01 20:39:46 UTC (rev 94340)
@@ -820,6 +820,12 @@
     statistics->set("_javascript_ProtectedObjectTypeCounts", createDictionaryFromHashMap(statisticsData._javascript_ProtectedObjectTypeCounts).get());
     statistics->set("_javascript_ObjectTypeCounts", createDictionaryFromHashMap(statisticsData._javascript_ObjectTypeCounts).get());
     
+    size_t cacheStatisticsCount = statisticsData.webCoreCacheStatistics.size();
+    Vector<RefPtr<APIObject> > cacheStatisticsVector(cacheStatisticsCount);
+    for (size_t i = 0; i < cacheStatisticsCount; ++i)
+        cacheStatisticsVector[i] = createDictionaryFromHashMap(statisticsData.webCoreCacheStatistics[i]);
+    statistics->set("WebCoreCacheStatistics", ImmutableArray::adopt(cacheStatisticsVector).get());
+    
     callback->performCallbackWithReturnValue(statistics.get());
 }
     

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (94339 => 94340)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-09-01 20:38:22 UTC (rev 94339)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-09-01 20:39:46 UTC (rev 94340)
@@ -833,6 +833,82 @@
         map.set(it->first, it->second);
 }
 
+static void getWebCoreMemoryCacheStatistics(Vector<HashMap<String, uint64_t> >& result)
+{
+    DEFINE_STATIC_LOCAL(String, imagesString, ("Images"));
+    DEFINE_STATIC_LOCAL(String, cssString, ("CSS"));
+    DEFINE_STATIC_LOCAL(String, xslString, ("XSL"));
+    DEFINE_STATIC_LOCAL(String, _javascript_String, ("_javascript_"));
+    
+    MemoryCache::Statistics memoryCacheStatistics = memoryCache()->getStatistics();
+    
+    HashMap<String, uint64_t> counts;
+    counts.set(imagesString, memoryCacheStatistics.images.count);
+    counts.set(cssString, memoryCacheStatistics.cssStyleSheets.count);
+#if ENABLE(XSLT)
+    counts.set(xslString, memoryCacheStatistics.xslStyleSheets.count);
+#else
+    counts.set(xslString, 0);
+#endif
+    counts.set(_javascript_String, memoryCacheStatistics.scripts.count);
+    result.append(counts);
+    
+    HashMap<String, uint64_t> sizes;
+    sizes.set(imagesString, memoryCacheStatistics.images.size);
+    sizes.set(cssString, memoryCacheStatistics.cssStyleSheets.size);
+#if ENABLE(XSLT)
+    sizes.set(xslString, memoryCacheStatistics.xslStyleSheets.size);
+#else
+    sizes.set(xslString, 0);
+#endif
+    sizes.set(_javascript_String, memoryCacheStatistics.scripts.size);
+    result.append(sizes);
+    
+    HashMap<String, uint64_t> liveSizes;
+    liveSizes.set(imagesString, memoryCacheStatistics.images.liveSize);
+    liveSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.liveSize);
+#if ENABLE(XSLT)
+    liveSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.liveSize);
+#else
+    liveSizes.set(xslString, 0);
+#endif
+    liveSizes.set(_javascript_String, memoryCacheStatistics.scripts.liveSize);
+    result.append(liveSizes);
+    
+    HashMap<String, uint64_t> decodedSizes;
+    decodedSizes.set(imagesString, memoryCacheStatistics.images.decodedSize);
+    decodedSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.decodedSize);
+#if ENABLE(XSLT)
+    decodedSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.decodedSize);
+#else
+    decodedSizes.set(xslString, 0);
+#endif
+    decodedSizes.set(_javascript_String, memoryCacheStatistics.scripts.decodedSize);
+    result.append(decodedSizes);
+    
+    HashMap<String, uint64_t> purgeableSizes;
+    purgeableSizes.set(imagesString, memoryCacheStatistics.images.purgeableSize);
+    purgeableSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.purgeableSize);
+#if ENABLE(XSLT)
+    purgeableSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.purgeableSize);
+#else
+    purgeableSizes.set(xslString, 0);
+#endif
+    purgeableSizes.set(_javascript_String, memoryCacheStatistics.scripts.purgeableSize);
+    result.append(purgeableSizes);
+    
+    HashMap<String, uint64_t> purgedSizes;
+    purgedSizes.set(imagesString, memoryCacheStatistics.images.purgedSize);
+    purgedSizes.set(cssString, memoryCacheStatistics.cssStyleSheets.purgedSize);
+#if ENABLE(XSLT)
+    purgedSizes.set(xslString, memoryCacheStatistics.xslStyleSheets.purgedSize);
+#else
+    purgedSizes.set(xslString, 0);
+#endif
+    purgedSizes.set(_javascript_String, memoryCacheStatistics.scripts.purgedSize);
+    result.append(purgedSizes);
+}
+
 void WebProcess::getWebCoreStatistics(uint64_t callbackID)
 {
     StatisticsData data;
@@ -874,7 +950,8 @@
     // Gather glyph page statistics.
     data.statisticsNumbers.set("GlyphPageCount", GlyphPageTreeNode::treeGlyphPageCount());
     
-    // FIXME: Gather WebCore cache statistics.
+    // Get WebCore memory cache statistics
+    getWebCoreMemoryCacheStatistics(data.webCoreCacheStatistics);
     
     m_connection->send(Messages::WebContext::DidGetWebCoreStatistics(data, callbackID), 0);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to