Title: [118361] trunk/Source/WebCore
Revision
118361
Author
[email protected]
Date
2012-05-24 06:39:04 -0700 (Thu, 24 May 2012)

Log Message

Web Inspector: convert HeapSnapshotGridNode._provider into getter.
https://bugs.webkit.org/show_bug.cgi?id=87382

I found that we create a provider for child nodes for the each DataGrid node in advance.
It cost us one async call to the HeapSnapshot's worker per each such the node.
I converted the property into the getter which is initializing the provider lazily.

Reviewed by Yury Semikhatsky.

* inspector/front-end/HeapSnapshot.js:
* inspector/front-end/HeapSnapshotGridNodes.js:
(WebInspector.HeapSnapshotGridNode):
(WebInspector.HeapSnapshotGridNode.prototype.createProvider):
(WebInspector.HeapSnapshotGridNode.prototype._provider):
(WebInspector.HeapSnapshotGridNode.prototype.dispose):
(WebInspector.HeapSnapshotGridNode.prototype._populate):
(WebInspector.HeapSnapshotGridNode.prototype.expandWithoutPopulate):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.serializeNextChunk):
(WebInspector.HeapSnapshotGridNode.prototype.sort):
(WebInspector.HeapSnapshotGenericObjectNode):
(WebInspector.HeapSnapshotGenericObjectNode.prototype.updateHasChildren):
(WebInspector.HeapSnapshotObjectNode):
(WebInspector.HeapSnapshotInstanceNode):
(WebInspector.HeapSnapshotConstructorNode):
(WebInspector.HeapSnapshotConstructorNode.prototype.createProvider):
(WebInspector.HeapSnapshotConstructorNode.prototype.revealNodeBySnapshotObjectId):
(WebInspector.HeapSnapshotDiffNode):
(WebInspector.HeapSnapshotDiffNode.prototype.createProvider):
(WebInspector.HeapSnapshotDominatorObjectNode):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.createProvider):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118360 => 118361)


--- trunk/Source/WebCore/ChangeLog	2012-05-24 13:32:02 UTC (rev 118360)
+++ trunk/Source/WebCore/ChangeLog	2012-05-24 13:39:04 UTC (rev 118361)
@@ -1,3 +1,37 @@
+2012-05-24  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: convert HeapSnapshotGridNode._provider into getter.
+        https://bugs.webkit.org/show_bug.cgi?id=87382
+
+        I found that we create a provider for child nodes for the each DataGrid node in advance.
+        It cost us one async call to the HeapSnapshot's worker per each such the node.
+        I converted the property into the getter which is initializing the provider lazily.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/HeapSnapshot.js:
+        * inspector/front-end/HeapSnapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGridNode):
+        (WebInspector.HeapSnapshotGridNode.prototype.createProvider):
+        (WebInspector.HeapSnapshotGridNode.prototype._provider):
+        (WebInspector.HeapSnapshotGridNode.prototype.dispose):
+        (WebInspector.HeapSnapshotGridNode.prototype._populate):
+        (WebInspector.HeapSnapshotGridNode.prototype.expandWithoutPopulate):
+        (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.serializeNextChunk):
+        (WebInspector.HeapSnapshotGridNode.prototype.sort):
+        (WebInspector.HeapSnapshotGenericObjectNode):
+        (WebInspector.HeapSnapshotGenericObjectNode.prototype.updateHasChildren):
+        (WebInspector.HeapSnapshotObjectNode):
+        (WebInspector.HeapSnapshotInstanceNode):
+        (WebInspector.HeapSnapshotConstructorNode):
+        (WebInspector.HeapSnapshotConstructorNode.prototype.createProvider):
+        (WebInspector.HeapSnapshotConstructorNode.prototype.revealNodeBySnapshotObjectId):
+        (WebInspector.HeapSnapshotDiffNode):
+        (WebInspector.HeapSnapshotDiffNode.prototype.createProvider):
+        (WebInspector.HeapSnapshotDominatorObjectNode):
+        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.createProvider):
+        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):
+
 2012-05-24  Rakesh KN  <[email protected]>
 
         Filter for RadioNodeList should be case sensitive.

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (118360 => 118361)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-05-24 13:32:02 UTC (rev 118360)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-05-24 13:39:04 UTC (rev 118361)
@@ -846,7 +846,9 @@
     },
 
     /**
-     * @param {String=} filterString
+     * @param {boolean} sortedIndexes
+     * @param {string} key
+     * @param {string=} filterString
      */
     aggregates: function(sortedIndexes, key, filterString)
     {

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js (118360 => 118361)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js	2012-05-24 13:32:02 UTC (rev 118360)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js	2012-05-24 13:39:04 UTC (rev 118361)
@@ -33,15 +33,10 @@
  * @extends {WebInspector.DataGridNode}
  * @param {WebInspector.HeapSnapshotSortableDataGrid} tree
  * @param {boolean} hasChildren
- * @param {WebInspector.HeapSnapshotProviderProxy|WebInspector.HeapSnapshotDiffNodesProvider} provider
  */
-WebInspector.HeapSnapshotGridNode = function(tree, hasChildren, provider)
+WebInspector.HeapSnapshotGridNode = function(tree, hasChildren)
 {
     WebInspector.DataGridNode.call(this, null, hasChildren);
-    /**
-     * @type {WebInspector.HeapSnapshotProviderProxy|WebInspector.HeapSnapshotDiffNodesProvider}
-     */
-    this._provider = provider;
     this._dataGrid = tree;
     this._instanceCount = 0;
 
@@ -55,6 +50,24 @@
 }
 
 WebInspector.HeapSnapshotGridNode.prototype = {
+    /**
+     * @return {WebInspector.HeapSnapshotProviderProxy}
+     */
+    createProvider: function()
+    {
+        throw new Error("Needs implemented.");
+    },
+
+    /**
+     * @return {WebInspector.HeapSnapshotProviderProxy}
+     */
+    _provider: function()
+    {
+        if (!this._providerObject)
+            this._providerObject = this.createProvider();
+        return this._providerObject;
+    },
+
     createCell: function(columnIdentifier)
     {
         var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
@@ -71,8 +84,8 @@
 
     dispose: function()
     {
-        if (this._provider)
-            this._provider.dispose();
+        if (this._provider())
+            this._provider().dispose();
         for (var node = this.children[0]; node; node = node.traverseNextNode(true, this, true))
             if (node.dispose)
                 node.dispose();
@@ -142,7 +155,7 @@
         {
             this._populateChildren();
         }
-        this._provider.sortAndRewind(this.comparator(), sorted.bind(this));
+        this._provider().sortAndRewind(this.comparator(), sorted.bind(this));
     },
 
     expandWithoutPopulate: function(callback)
@@ -150,7 +163,7 @@
         // Make sure default _populate won't be invoked.
         this.removeEventListener("populate", this._populate, this);
         this.expand();
-        this._provider.sortAndRewind(this.comparator(), callback);
+        this._provider().sortAndRewind(this.comparator(), callback);
     },
 
     /**
@@ -167,7 +180,7 @@
             if (firstNotSerializedPosition >= toPosition)
                 return;
             var end = Math.min(firstNotSerializedPosition + this._dataGrid.defaultPopulateCount(), toPosition);
-            this._provider.serializeItemsRange(firstNotSerializedPosition, end, childrenRetrieved.bind(this));
+            this._provider().serializeItemsRange(firstNotSerializedPosition, end, childrenRetrieved.bind(this));
             firstNotSerializedPosition = end;
         }
         function insertRetrievedChild(item, insertionIndex)
@@ -317,7 +330,7 @@
             this._populateChildren(0, instanceCount, afterPopulate.bind(this));
         }
 
-        this._provider.sortAndRewind(this.comparator(), afterSort.bind(this));
+        this._provider().sortAndRewind(this.comparator(), afterSort.bind(this));
     }
 };
 
@@ -326,11 +339,12 @@
 /**
  * @constructor
  * @extends {WebInspector.HeapSnapshotGridNode}
- * @param {WebInspector.HeapSnapshotProviderProxy} provider
+ * @param {WebInspector.HeapSnapshotSortableDataGrid} tree
  */
-WebInspector.HeapSnapshotGenericObjectNode = function(tree, node, provider)
+WebInspector.HeapSnapshotGenericObjectNode = function(tree, node)
 {
-    WebInspector.HeapSnapshotGridNode.call(this, tree, false, provider);
+    this.snapshotNodeIndex = 0;
+    WebInspector.HeapSnapshotGridNode.call(this, tree, false);
     // node is null for DataGrid root nodes.
     if (!node)
         return;
@@ -471,7 +485,7 @@
         {
             this.hasChildren = !isEmpty;
         }
-        this._provider.isEmpty(isEmptyCallback.bind(this));
+        this._provider().isEmpty(isEmptyCallback.bind(this));
     },
 
     isWindow: function(fullName)
@@ -504,8 +518,7 @@
  */
 WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge, parentGridNode)
 {
-    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node,
-        WebInspector.HeapSnapshotObjectNode._createProvider(isFromBaseSnapshot, edge.nodeIndex, tree));
+    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node);
     this._referenceName = edge.name;
     this._referenceType = edge.type;
     this._propertyAccessor = edge.propertyAccessor;
@@ -519,22 +532,26 @@
         this.updateHasChildren();
 }
 
-WebInspector.HeapSnapshotObjectNode._createProvider = function(isFromBaseSnapshot, nodeIndex, tree)
-{
-    var showHiddenData = WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get();
-    var filter = "function(edge) {\n" +
-        "    return !edge.isInvisible()\n" +
-        "        && (" + !tree.showRetainingEdges + " || (edge.node().id() !== 1 && !edge.node().isSynthetic()))\n" +
-        "        && (" + showHiddenData + " || (!edge.isHidden() && !edge.node().isHidden()));\n" +
-        "}\n";
-    var snapshot = isFromBaseSnapshot ? tree.baseSnapshot : tree.snapshot;
-    if (tree.showRetainingEdges)
-        return snapshot.createRetainingEdgesProvider(nodeIndex, filter);
-    else
-        return snapshot.createEdgesProvider(nodeIndex, filter);
-}
+WebInspector.HeapSnapshotObjectNode.prototype = {
+    /**
+     * @return {WebInspector.HeapSnapshotProviderProxy}
+     */
+    createProvider: function()
+    {
+        var tree = this._dataGrid;
+        var showHiddenData = WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get();
+        var filter = "function(edge) {\n" +
+                     "    return !edge.isInvisible()\n" +
+                     "        && (" + !tree.showRetainingEdges + " || (edge.node().id() !== 1 && !edge.node().isSynthetic()))\n" +
+                     "        && (" + showHiddenData + " || (!edge.isHidden() && !edge.node().isHidden()));\n" +
+                     "}\n";
+        var snapshot = this._isFromBaseSnapshot ? tree.baseSnapshot : tree.snapshot;
+        if (this.showRetainingEdges)
+            return snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex, filter);
+        else
+            return snapshot.createEdgesProvider(this.snapshotNodeIndex, filter);
+    },
 
-WebInspector.HeapSnapshotObjectNode.prototype = {
     _findAncestorWithSameSnapshotNodeId: function()
     {
         var ancestor = this._parentGridNode;
@@ -630,24 +647,24 @@
  */
 WebInspector.HeapSnapshotInstanceNode = function(tree, baseSnapshot, snapshot, node)
 {
-    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node,
-        WebInspector.HeapSnapshotInstanceNode._createProvider(baseSnapshot || snapshot, node.nodeIndex));
+    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node);
+    this._baseSnapshotOrSnapshot = baseSnapshot || snapshot;
     this._isDeletedNode = !!baseSnapshot;
     this.updateHasChildren();
 };
 
-WebInspector.HeapSnapshotInstanceNode._createProvider = function(snapshot, nodeIndex)
-{
-    var showHiddenData = WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get();
-    return snapshot.createEdgesProvider(
-        nodeIndex,
-        "function(edge) {" +
-        "    return !edge.isInvisible()" +
-        "        && (" + showHiddenData + " || (!edge.isHidden() && !edge.node().isHidden()));" +
-        "}");
-}
+WebInspector.HeapSnapshotInstanceNode.prototype = {
+    createProvider: function()
+    {
+        var showHiddenData = WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get();
+        return this._baseSnapshotOrSnapshot.createEdgesProvider(
+            this.snapshotNodeIndex,
+            "function(edge) {" +
+            "    return !edge.isInvisible()" +
+            "        && (" + showHiddenData + " || (!edge.isHidden() && !edge.node().isHidden()));" +
+            "}");
+    },
 
-WebInspector.HeapSnapshotInstanceNode.prototype = {
     _createChildNode: function(item)
     {
         return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._isDeletedNode, item, null);
@@ -714,9 +731,9 @@
  */
 WebInspector.HeapSnapshotConstructorNode = function(tree, className, aggregate, aggregatesKey)
 {
-    WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0,
-        tree.snapshot.createNodesProviderForClass(className, aggregatesKey));
+    WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0);
     this._name = className;
+    this._aggregatesKey = aggregatesKey;
     this._distanceToWindow = aggregate.distanceToWindow;
     this._count = aggregate.count;
     this._shallowSize = aggregate.self;
@@ -725,13 +742,22 @@
 
 WebInspector.HeapSnapshotConstructorNode.prototype = {
     /**
+     * @override
+     * @return {WebInspector.HeapSnapshotProviderProxy}
+     */
+    createProvider: function()
+    {
+        return this._dataGrid.snapshot.createNodesProviderForClass(this._name, this._aggregatesKey)
+    },
+
+    /**
      * @param {number} snapshotObjectId
      */
     revealNodeBySnapshotObjectId: function(snapshotObjectId)
     {
         function didExpand()
         {
-            this._provider.nodePosition(snapshotObjectId, didGetNodePosition.bind(this));
+            this._provider().nodePosition(snapshotObjectId, didGetNodePosition.bind(this));
         }
 
         function didGetNodePosition(nodePosition)
@@ -908,8 +934,7 @@
  */
 WebInspector.HeapSnapshotDiffNode = function(tree, className, diffForClass)
 {
-    WebInspector.HeapSnapshotGridNode.call(this, tree, true,
-        WebInspector.HeapSnapshotDiffNode._createProvider(tree, className, diffForClass.deletedIndexes, diffForClass.addedCount, diffForClass.removedCount));
+    WebInspector.HeapSnapshotGridNode.call(this, tree, true);
     this._name = className;
 
     this._addedCount = diffForClass.addedCount;
@@ -918,18 +943,24 @@
     this._addedSize = diffForClass.addedSize;
     this._removedSize = diffForClass.removedSize;
     this._sizeDelta = diffForClass.sizeDelta;
+    this._deletedIndexes = diffForClass.deletedIndexes;
 }
 
-WebInspector.HeapSnapshotDiffNode._createProvider = function(tree, className, deletedIndexes, addedCount, removedCount)
-{
-    var result =  new WebInspector.HeapSnapshotDiffNodesProvider(
-        tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, className),
-        tree.baseSnapshot.createDeletedNodesProvider(deletedIndexes),
-        addedCount, removedCount);
-    return result;
-}
+WebInspector.HeapSnapshotDiffNode.prototype = {
+    /**
+     * @override
+     * @return {WebInspector.HeapSnapshotDiffNodesProvider}
+     */
+    createProvider: function()
+    {
+        var tree = this._dataGrid;
+        return  new WebInspector.HeapSnapshotDiffNodesProvider(
+            tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._name),
+            tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes),
+            this._addedCount,
+            this._removedCount);
+    },
 
-WebInspector.HeapSnapshotDiffNode.prototype = {
     _createChildNode: function(item)
     {
         if (item.isAddedNotRemoved)
@@ -997,13 +1028,21 @@
  */
 WebInspector.HeapSnapshotDominatorObjectNode = function(tree, node)
 {
-    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node,
-        tree.snapshot.createNodesProviderForDominator(node.nodeIndex));
+    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node);
     this.updateHasChildren();
 };
 
 WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
     /**
+     * @override
+     * @return {WebInspector.HeapSnapshotProviderProxy}
+     */
+    createProvider: function()
+    {
+        return this._dataGrid.snapshot.createNodesProviderForDominator(this.snapshotNodeIndex);
+    },
+
+    /**
      * @param {number} snapshotObjectId
      * @param {function(?WebInspector.HeapSnapshotDominatorObjectNode)} callback
      */
@@ -1011,7 +1050,7 @@
     {
         function didExpand()
         {
-            this._provider.nodePosition(snapshotObjectId, didGetNodePosition.bind(this));
+            this._provider().nodePosition(snapshotObjectId, didGetNodePosition.bind(this));
         }
 
         function didGetNodePosition(nodePosition)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to