Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 2766943002: Do-not-commit: Count layout tree memory usage
Patch Set: Rebase, add object paint property counter Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/layout/LayoutBR.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/FrameView.cpp
diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp
index 91c82bdcf3276ac701da5bd92e86ee05da3e6acf..c0baa17635d8a3166670fe5bb76fd850c9de5be9 100644
--- a/third_party/WebKit/Source/core/frame/FrameView.cpp
+++ b/third_party/WebKit/Source/core/frame/FrameView.cpp
@@ -1336,6 +1336,135 @@ void FrameView::layout() {
frame().document()->layoutUpdated();
checkDoesNotNeedLayout();
+
+ printLayoutTreeStats();
+}
+
+struct TreeStats {
+ int frames;
+ int layoutObjects;
+ int objectPaintProperties;
+ int layoutObjectMemory;
+ int layoutTreeApproximateHeapMemoryUsage;
+ int paintPropertiesMemoryUsage;
+ int paintPropertyTransformNodes;
+ int paintPropertyScrollNodes;
+ int paintPropertyClipNodes;
+ int paintPropertyEffectNodes;
+ int borderBoxProperties;
+ int contentsProperties;
+};
+
+void FrameView::printLayoutTreeStats() const {
+ TreeStats stats = {};
+ countLayoutTreeStats(stats, *this);
+ LOG(ERROR) << "Layout Tree Stats -------------";
+ LOG(ERROR) << " frame count: " << stats.frames;
+ LOG(ERROR) << " layout object count: " << stats.layoutObjects;
+ LOG(ERROR) << " layout object memory: " << stats.layoutObjectMemory
+ << " bytes";
+ LOG(ERROR) << " layout tree additional heap memory: "
+ << stats.layoutTreeApproximateHeapMemoryUsage << " bytes";
+ LOG(ERROR) << " object paint properties: " << stats.objectPaintProperties;
+ LOG(ERROR) << " paint properties memory: "
+ << stats.paintPropertiesMemoryUsage << " bytes";
+ LOG(ERROR) << " transform nodes (" << sizeof(TransformPaintPropertyNode)
+ << " bytes): " << stats.paintPropertyTransformNodes;
+ LOG(ERROR) << " scroll nodes (" << sizeof(ScrollPaintPropertyNode)
+ << " bytes): " << stats.paintPropertyScrollNodes;
+ LOG(ERROR) << " clip nodes (" << sizeof(ClipPaintPropertyNode)
+ << " bytes): " << stats.paintPropertyClipNodes;
+ LOG(ERROR) << " effect nodes (" << sizeof(EffectPaintPropertyNode)
+ << " bytes): " << stats.paintPropertyEffectNodes;
+ LOG(ERROR) << " border box properties (" << sizeof(PropertyTreeState)
+ << " bytes): " << stats.borderBoxProperties;
+ LOG(ERROR) << " contents properties (" << sizeof(PropertyTreeState)
+ << " bytes): " << stats.contentsProperties;
+}
+
+void FrameView::countLayoutTreeStats(TreeStats& stats,
+ const FrameView& frame) const {
+ stats.frames++;
+ if (frame.m_preTranslation) {
+ stats.paintPropertyTransformNodes++;
+ stats.paintPropertiesMemoryUsage += sizeof(TransformPaintPropertyNode);
+ }
+ if (frame.m_scrollTranslation) {
+ stats.paintPropertyTransformNodes++;
+ stats.paintPropertyScrollNodes++;
+ stats.paintPropertiesMemoryUsage += sizeof(TransformPaintPropertyNode);
+ stats.paintPropertiesMemoryUsage += sizeof(ScrollPaintPropertyNode);
+ }
+ if (frame.m_contentClip) {
+ stats.paintPropertyClipNodes++;
+ stats.paintPropertiesMemoryUsage += sizeof(ClipPaintPropertyNode);
+ }
+ if (frame.m_totalPropertyTreeStateForContents) {
+ stats.paintPropertiesMemoryUsage += sizeof(PropertyTreeState);
+ }
+ if (LayoutView* view = frame.layoutView())
+ countLayoutTreeStats(stats, *view);
+}
+
+void FrameView::countLayoutTreeStats(TreeStats& stats,
+ const LayoutObject& object) const {
+ stats.layoutObjects++;
+ stats.layoutObjectMemory += object.objectSize();
+ stats.layoutTreeApproximateHeapMemoryUsage +=
+ object.approximateHeapMemoryUsage();
+
+ if (const auto* properties = object.paintProperties()) {
+ stats.objectPaintProperties++;
+ stats.paintPropertiesMemoryUsage += sizeof(ObjectPaintProperties);
+ stats.paintPropertiesMemoryUsage += properties->heapMemoryUsage();
+
+ if (properties->paintOffsetTranslation())
+ stats.paintPropertyTransformNodes++;
+ if (properties->transform())
+ stats.paintPropertyTransformNodes++;
+ if (properties->effect())
+ stats.paintPropertyEffectNodes++;
+ if (properties->filter())
+ stats.paintPropertyEffectNodes++;
+ if (properties->mask())
+ stats.paintPropertyEffectNodes++;
+ if (properties->maskClip())
+ stats.paintPropertyClipNodes++;
+ if (properties->cssClip())
+ stats.paintPropertyClipNodes++;
+ if (properties->cssClipFixedPosition())
+ stats.paintPropertyClipNodes++;
+ if (properties->innerBorderRadiusClip())
+ stats.paintPropertyClipNodes++;
+ if (properties->overflowClip())
+ stats.paintPropertyClipNodes++;
+ if (properties->perspective())
+ stats.paintPropertyTransformNodes++;
+ if (properties->svgLocalToBorderBoxTransform())
+ stats.paintPropertyTransformNodes++;
+ if (properties->scrollTranslation()) {
+ stats.paintPropertyTransformNodes++;
+ stats.paintPropertyScrollNodes++;
+ }
+ if (properties->scrollbarPaintOffset())
+ stats.paintPropertyTransformNodes++;
+
+ if (properties->localBorderBoxProperties())
+ stats.borderBoxProperties++;
+ if (properties->hasContentsProperties())
+ stats.contentsProperties++;
+ }
+
+ for (const LayoutObject* child = object.slowFirstChild(); child;
+ child = child->nextSibling()) {
+ countLayoutTreeStats(stats, *child);
+ }
+ if (object.isLayoutPart()) {
+ const LayoutPart& layoutPart = toLayoutPart(object);
+ FrameViewBase* frameViewBase = layoutPart.frameViewBase();
+ if (frameViewBase && frameViewBase->isFrameView())
+ countLayoutTreeStats(stats, *toFrameView(frameViewBase));
+ }
}
void FrameView::invalidateTreeIfNeeded(
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.h ('k') | third_party/WebKit/Source/core/layout/LayoutBR.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698