Add a histogram for rendertree size
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2012 01:24:40 +0000 (01:24 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2012 01:24:40 +0000 (01:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85226

Reviewed by Eric Seidel.

Source/WebCore:

We record it when the page gets hidden, since this is a point
at which, in theory, we could kill the rendertree.

No new tests. This isn't web visible, so there's no way to test it.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::clear):
* page/Page.cpp:
(WebCore::Page::renderTreeSize):
(WebCore):
(WebCore::Page::setVisibilityState):
* page/Page.h:
(Page):
* platform/HistogramSupport.cpp:
(WebCore::HistogramSupport::histogramCustomCounts):
(WebCore):
* platform/HistogramSupport.h:
(HistogramSupport):
* platform/chromium/HistogramSupportChromium.cpp:
(WebCore::HistogramSupport::histogramCustomCounts):
(WebCore):

Source/WebKit2:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::renderTreeSize):
Move the renderTreeSize code into Page.cpp, so it can be reused.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115924 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/HistogramSupport.cpp
Source/WebCore/platform/HistogramSupport.h
Source/WebCore/platform/chromium/HistogramSupportChromium.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 3d282c0..02bca21 100644 (file)
@@ -1,3 +1,32 @@
+2012-05-02  Ojan Vafai  <ojan@chromium.org>
+
+        Add a histogram for rendertree size
+        https://bugs.webkit.org/show_bug.cgi?id=85226
+
+        Reviewed by Eric Seidel.
+
+        We record it when the page gets hidden, since this is a point
+        at which, in theory, we could kill the rendertree.
+
+        No new tests. This isn't web visible, so there's no way to test it.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::clear):
+        * page/Page.cpp:
+        (WebCore::Page::renderTreeSize):
+        (WebCore):
+        (WebCore::Page::setVisibilityState):
+        * page/Page.h:
+        (Page):
+        * platform/HistogramSupport.cpp:
+        (WebCore::HistogramSupport::histogramCustomCounts):
+        (WebCore):
+        * platform/HistogramSupport.h:
+        (HistogramSupport):
+        * platform/chromium/HistogramSupportChromium.cpp:
+        (WebCore::HistogramSupport::histogramCustomCounts):
+        (WebCore):
+
 2012-05-02  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r115902.
index 16f5212..9ff6b69 100644 (file)
@@ -1418,6 +1418,7 @@ __ZNK7WebCore4Node18getSubresourceURLsERN3WTF11ListHashSetINS_4KURLELm256ENS_8KU
 __ZNK7WebCore4Node20traversePreviousNodeEPKS0_
 __ZNK7WebCore4Node9nodeIndexEv
 __ZNK7WebCore4Page10pluginDataEv
+__ZNK7WebCore4Page14renderTreeSizeEv
 __ZNK7WebCore4Page15backForwardListEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore4Page9groupNameEv
index c07226e..2f5ab52 100644 (file)
@@ -44,6 +44,7 @@
 #include "FrameTree.h"
 #include "FrameView.h"
 #include "HTMLElement.h"
+#include "HistogramSupport.h"
 #include "HistoryItem.h"
 #include "InspectorController.h"
 #include "InspectorInstrumentation.h"
@@ -57,6 +58,7 @@
 #include "PluginViewBase.h"
 #include "PointerLockController.h"
 #include "ProgressTracker.h"
+#include "RenderArena.h"
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
@@ -207,6 +209,16 @@ Page::~Page()
 
 }
 
+size_t Page::renderTreeSize() const
+{
+    size_t size = 0;
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (frame->document() && frame->document()->renderArena())
+            size += frame->document()->renderArena()->totalRenderArenaSize();
+    }
+    return size;
+}
+
 ViewportArguments Page::viewportArguments() const
 {
     return mainFrame() && mainFrame()->document() ? mainFrame()->document()->viewportArguments() : ViewportArguments();
@@ -1006,8 +1018,11 @@ void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
         return;
     m_visibilityState = visibilityState;
 
-    if (!isInitialState && m_mainFrame)
+    if (!isInitialState && m_mainFrame) {
+        if (visibilityState == PageVisibilityStateHidden)
+            HistogramSupport::histogramCustomCounts("WebCore.Page.renderTreeSizeBytes", renderTreeSize(), 1000, 500000000, 50);
         m_mainFrame->dispatchVisibilityStateChangeEvent();
+    }
 }
 
 PageVisibilityState Page::visibilityState() const
index d97c45f..adafc51 100644 (file)
@@ -118,6 +118,8 @@ namespace WebCore {
         Page(PageClients&);
         ~Page();
 
+        size_t renderTreeSize() const;
+
         void setNeedsRecalcStyleInAllFrames();
 
         RenderTheme* theme() const { return m_theme.get(); };
index 8052fda..d9ea79c 100644 (file)
@@ -37,4 +37,8 @@ void HistogramSupport::histogramEnumeration(const char*, int, int)
 {
 }
 
+void HistogramSupport::histogramCustomCounts(const char*, int, int, int, int)
+{
+}
+
 } // namespace WebCore
index 5811e32..9bb265a 100644 (file)
@@ -36,6 +36,7 @@ namespace WebCore {
 class HistogramSupport {
 public:
     static void histogramEnumeration(const char* name, int sample, int boundaryValue);
+    static void histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount);
 };
 
 } // namespace WebCore
index 4be0a8a..52e0b5e 100644 (file)
@@ -40,4 +40,9 @@ void HistogramSupport::histogramEnumeration(const char* name, int sample, int bo
     WebKit::Platform::current()->histogramEnumeration(name, sample, boundaryValue);
 }
 
+void HistogramSupport::histogramCustomCounts(const char* name, int sample, int min, int max, int bucketCount)
+{
+    WebKit::Platform::current()->histogramCustomCounts(name, sample, min, max, bucketCount);
+}
+
 } // namespace WebCore
index 1c391dd..2b84b28 100644 (file)
@@ -1,3 +1,14 @@
+2012-05-02  Ojan Vafai  <ojan@chromium.org>
+
+        Add a histogram for rendertree size
+        https://bugs.webkit.org/show_bug.cgi?id=85226
+
+        Reviewed by Eric Seidel.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::renderTreeSize):
+        Move the renderTreeSize code into Page.cpp, so it can be reused.
+
 2012-05-02  Anders Carlsson  <andersca@apple.com>
 
         PDF page does not show up when opened in the background
index c88ea7f..7a84409 100644 (file)
@@ -98,7 +98,6 @@
 #include <WebCore/PlatformKeyboardEvent.h>
 #include <WebCore/PluginDocument.h>
 #include <WebCore/PrintContext.h>
-#include <WebCore/RenderArena.h>
 #include <WebCore/RenderLayer.h>
 #include <WebCore/RenderTreeAsText.h>
 #include <WebCore/RenderView.h>
@@ -502,16 +501,7 @@ uint64_t WebPage::renderTreeSize() const
 {
     if (!m_page)
         return 0;
-
-    Frame* mainFrame = m_page->mainFrame();
-    if (!mainFrame)
-        return 0;
-
-    uint64_t size = 0;
-    for (Frame* coreFrame = mainFrame; coreFrame; coreFrame = coreFrame->tree()->traverseNext())
-        size += coreFrame->document()->renderArena()->totalRenderArenaSize();
-
-    return size;
+    return m_page->renderTreeSize();
 }
 
 void WebPage::setPaintedObjectsCounterThreshold(uint64_t threshold)