Web Inspector: showing summary view is very slow on a snapshot with thousands of...
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 12:52:04 +0000 (12:52 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2012 12:52:04 +0000 (12:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83682

Node content is created only when the node becomes visible in the corresponding view.
This saves a lot of time when openning summary/comparison view of a snapshot
with lots of different classes.

Reviewed by Pavel Feldman.

* inspector/front-end/DetailedHeapshotGridNodes.js:
(WebInspector.HeapSnapshotGridNode.prototype.ensureContentCreated):
(WebInspector.HeapSnapshotLazyGridNode):
(WebInspector.HeapSnapshotLazyGridNode.prototype.ensureContentCreated):
(WebInspector.HeapSnapshotLazyGridNode.prototype.createCells):
(WebInspector.HeapSnapshotConstructorNode):
(WebInspector.HeapSnapshotDiffNode):
* inspector/front-end/DetailedHeapshotView.js:
(WebInspector.HeapSnapshotSortableDataGrid):
(WebInspector.HeapSnapshotSortableDataGrid.prototype.updateVisibleNodes):
(WebInspector.HeapSnapshotSortableDataGrid.prototype.onResize):
(WebInspector.HeapSnapshotSortableDataGrid.prototype._onScroll):
(WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting):
(WebInspector.HeapSnapshotConstructorsDataGrid):
(WebInspector.HeapSnapshotDiffDataGrid):
(WebInspector.DetailedHeapshotView.prototype._changeNameFilter):
* inspector/front-end/heapProfiler.css:
(.detailed-heapshot-view .data-grid tr:empty):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js
Source/WebCore/inspector/front-end/heapProfiler.css

index b844354..c936042 100644 (file)
@@ -1,3 +1,33 @@
+2012-04-11  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: showing summary view is very slow on a snapshot with thousands of constructors
+        https://bugs.webkit.org/show_bug.cgi?id=83682
+
+        Node content is created only when the node becomes visible in the corresponding view.
+        This saves a lot of time when openning summary/comparison view of a snapshot
+        with lots of different classes.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/DetailedHeapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGridNode.prototype.ensureContentCreated):
+        (WebInspector.HeapSnapshotLazyGridNode):
+        (WebInspector.HeapSnapshotLazyGridNode.prototype.ensureContentCreated):
+        (WebInspector.HeapSnapshotLazyGridNode.prototype.createCells):
+        (WebInspector.HeapSnapshotConstructorNode):
+        (WebInspector.HeapSnapshotDiffNode):
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.HeapSnapshotSortableDataGrid):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.updateVisibleNodes):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.onResize):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype._onScroll):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting):
+        (WebInspector.HeapSnapshotConstructorsDataGrid):
+        (WebInspector.HeapSnapshotDiffDataGrid):
+        (WebInspector.DetailedHeapshotView.prototype._changeNameFilter):
+        * inspector/front-end/heapProfiler.css:
+        (.detailed-heapshot-view .data-grid tr:empty):
+
 2012-04-11  Simon Pena  <spena@igalia.com>
 
         [GTK] media/event-attributes.html fails
index 317341b..940de45 100644 (file)
@@ -37,6 +37,11 @@ WebInspector.HeapSnapshotGridNode = function(tree, hasChildren)
 }
 
 WebInspector.HeapSnapshotGridNode.prototype = {
+    ensureContentCreated: function()
+    {
+        // May be overriden in descendants with lazy content.
+    },
+
     createCell: function(columnIdentifier)
     {
         var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
@@ -198,6 +203,31 @@ WebInspector.HeapSnapshotGridNode.prototype = {
 
 WebInspector.HeapSnapshotGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype;
 
+WebInspector.HeapSnapshotLazyGridNode = function(tree, hasChildren)
+{
+    WebInspector.HeapSnapshotGridNode.call(this, tree, hasChildren);
+    this._deferContentCreation = true;
+}
+
+WebInspector.HeapSnapshotLazyGridNode.prototype = {
+    ensureContentCreated: function()
+    {
+        if (!this._deferContentCreation)
+            return;
+        this._deferContentCreation = false;
+        this.createCells();
+    },
+
+    createCells: function()
+    {
+        if (this._deferContentCreation)
+            return;
+        WebInspector.HeapSnapshotGridNode.prototype.createCells.call(this);
+    }
+};
+
+WebInspector.HeapSnapshotLazyGridNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
+
 WebInspector.HeapSnapshotGenericObjectNode = function(tree, node)
 {
     WebInspector.HeapSnapshotGridNode.call(this, tree, false);
@@ -569,7 +599,7 @@ WebInspector.HeapSnapshotInstanceNode.prototype.__proto__ = WebInspector.HeapSna
 
 WebInspector.HeapSnapshotConstructorNode = function(tree, className, aggregate, aggregatesKey)
 {
-    WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0);
+    WebInspector.HeapSnapshotLazyGridNode.call(this, tree, aggregate.count > 0);
     this._name = className;
     this._distanceToWindow = aggregate.distanceToWindow;
     this._count = aggregate.count;
@@ -651,7 +681,7 @@ WebInspector.HeapSnapshotConstructorNode.prototype = {
     }
 };
 
-WebInspector.HeapSnapshotConstructorNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
+WebInspector.HeapSnapshotConstructorNode.prototype.__proto__ = WebInspector.HeapSnapshotLazyGridNode.prototype;
 
 WebInspector.HeapSnapshotIteratorsTuple = function(it1, it2)
 {
@@ -678,7 +708,7 @@ WebInspector.HeapSnapshotIteratorsTuple.prototype = {
 
 WebInspector.HeapSnapshotDiffNode = function(tree, className, baseAggregate, aggregate)
 {
-    WebInspector.HeapSnapshotGridNode.call(this, tree, true);
+    WebInspector.HeapSnapshotLazyGridNode.call(this, tree, true);
     this._name = className;
     this._baseIndexes = baseAggregate ? baseAggregate.idxs : [];
     this._indexes = aggregate ? aggregate.idxs : [];
@@ -819,7 +849,7 @@ WebInspector.HeapSnapshotDiffNode.prototype = {
     }
 };
 
-WebInspector.HeapSnapshotDiffNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
+WebInspector.HeapSnapshotDiffNode.prototype.__proto__ = WebInspector.HeapSnapshotLazyGridNode.prototype;
 
 WebInspector.HeapSnapshotDominatorObjectNode = function(tree, node)
 {
index ad2f346..ad4bde0 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.HeapSnapshotSortableDataGrid = function(columns)
+WebInspector.HeapSnapshotSortableDataGrid = function(columns, deferNodeContentCreation)
 {
     WebInspector.DataGrid.call(this, columns);
     this.addEventListener("sorting changed", this.sortingChanged, this);
+
+    this._deferNodeContentCreation = deferNodeContentCreation;
+    if (deferNodeContentCreation)
+        this.scrollContainer.addEventListener("scroll", this._onScroll.bind(this), true);
 }
 
 WebInspector.HeapSnapshotSortableDataGrid.prototype = {
@@ -76,6 +80,47 @@ WebInspector.HeapSnapshotSortableDataGrid.prototype = {
         this._performSorting(SortByTwoFields);
     },
 
+    updateVisibleNodes: function()
+    {
+        if (!this._deferNodeContentCreation)
+            return;
+        var scrollTop = this.scrollContainer.scrollTop;
+        var rowHeight = 16;
+
+        var height = this.scrollContainer.offsetHeight;
+        var visibleRowsCount = Math.round(height / rowHeight) + 1;
+
+        var children = this.children;
+
+        var i = 0;
+        while (i < children.length) {
+            if (children[i].revealed) {
+                var top = children[i].element.offsetTop;
+                if (top >= scrollTop)
+                    break;
+            }
+            ++i;
+        }
+
+        while (i < children.length && visibleRowsCount) {
+            if (children[i].revealed) {
+                children[i].ensureContentCreated();
+                --visibleRowsCount;
+            }
+            ++i;
+        }
+    },
+
+    onResize: function()
+    {
+        this.updateVisibleNodes();
+    },
+
+    _onScroll: function(event)
+    {
+        this.updateVisibleNodes();
+    },
+
     _performSorting: function(sortFunction)
     {
         this.recursiveSortingEnter();
@@ -91,6 +136,7 @@ WebInspector.HeapSnapshotSortableDataGrid.prototype = {
                 child.sort();
         }
         this.recursiveSortingLeave();
+        this.updateVisibleNodes();
     },
 
     recursiveSortingEnter: function()
@@ -224,7 +270,7 @@ WebInspector.HeapSnapshotConstructorsDataGrid = function()
         shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "120px", sortable: true },
         retainedSize: { title: WebInspector.UIString("Retained Size"), width: "120px", sort: "descending", sortable: true }
     };
-    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
+    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns, true);
     this._profileIndex = -1;
 }
 
@@ -299,7 +345,7 @@ WebInspector.HeapSnapshotDiffDataGrid = function()
         removedSize: { title: WebInspector.UIString("Freed Size"), width: "72px", sortable: true },
         sizeDelta: { title: "Size Delta", width: "72px", sortable: true }
     };
-    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
+    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns, true);
 }
 
 WebInspector.HeapSnapshotDiffDataGrid.prototype = {
@@ -794,6 +840,7 @@ WebInspector.DetailedHeapshotView.prototype = {
             if (node.depth === 0)
                 node.revealed = node._name.toLowerCase().indexOf(filter) !== -1;
         }
+        this.dataGrid.updateVisibleNodes();
     },
 
     _profiles: function()
index c7527dd..757ff0f 100644 (file)
@@ -75,6 +75,11 @@ body.inactive .heap-snapshot-sidebar-tree-item.wait.selected .icon {
     display: block;
 }
 
+.detailed-heapshot-view .data-grid tr:empty {
+    height: 16px;
+    visibility: hidden;
+}
+
 .detailed-heapshot-view .data-grid {
     border: none;
 }