Title: [198358] trunk/Source/WebInspectorUI
Revision
198358
Author
[email protected]
Date
2016-03-17 16:25:40 -0700 (Thu, 17 Mar 2016)

Log Message

Web Inspector: Prefer retained size to the shallow size in Heap Snapshot data grids
https://bugs.webkit.org/show_bug.cgi?id=155597
<rdar://problem/25225087>

Patch by Joseph Pecoraro <[email protected]> on 2016-03-17
Reviewed by Timothy Hatcher.

* Localizations/en.lproj/localizedStrings.js:
New datagrid column and tooltip strings.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype.insertColumn):
Allow a column definition to provide a tooltip for the header cell.

* UserInterface/Views/HeapSnapshotClassDataGridNode.js:
(WebInspector.HeapSnapshotClassDataGridNode.prototype.createCellContent):
Include retained size column data.

(WebInspector.HeapSnapshotClassDataGridNode.prototype._populate):
Fix non-batched populate to sort instances on first population.

* UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
(WebInspector.HeapSnapshotInstanceDataGridNode.prototype.createCellContent):
Include retained size column data.

* UserInterface/Views/HeapSnapshotInstancesContentView.js:
(WebInspector.HeapSnapshotInstancesContentView):
Include a retained size column. Update initial sort and column widths.

* UserInterface/Views/HeapSnapshotInstancesDataGridTree.js:
(WebInspector.HeapSnapshotInstancesDataGridTree.buildSortComparator):
Include a numeric sort comparator for the new retained size column.

(WebInspector.HeapSnapshotInstancesDataGridTree.prototype._populateTopLevel):
Include retained size, and lazily calculate percentage later.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (198357 => 198358)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-03-17 23:25:40 UTC (rev 198358)
@@ -1,5 +1,42 @@
 2016-03-17  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Prefer retained size to the shallow size in Heap Snapshot data grids
+        https://bugs.webkit.org/show_bug.cgi?id=155597
+        <rdar://problem/25225087>
+
+        Reviewed by Timothy Hatcher.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New datagrid column and tooltip strings.
+
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid.prototype.insertColumn):
+        Allow a column definition to provide a tooltip for the header cell.
+
+        * UserInterface/Views/HeapSnapshotClassDataGridNode.js:
+        (WebInspector.HeapSnapshotClassDataGridNode.prototype.createCellContent):
+        Include retained size column data.
+
+        (WebInspector.HeapSnapshotClassDataGridNode.prototype._populate):
+        Fix non-batched populate to sort instances on first population.
+
+        * UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
+        (WebInspector.HeapSnapshotInstanceDataGridNode.prototype.createCellContent):
+        Include retained size column data.
+
+        * UserInterface/Views/HeapSnapshotInstancesContentView.js:
+        (WebInspector.HeapSnapshotInstancesContentView):
+        Include a retained size column. Update initial sort and column widths.
+
+        * UserInterface/Views/HeapSnapshotInstancesDataGridTree.js:
+        (WebInspector.HeapSnapshotInstancesDataGridTree.buildSortComparator):
+        Include a numeric sort comparator for the new retained size column.
+
+        (WebInspector.HeapSnapshotInstancesDataGridTree.prototype._populateTopLevel):
+        Include retained size, and lazily calculate percentage later.
+
+2016-03-17  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: HeapSnapshots are slow and use too much memory
         https://bugs.webkit.org/show_bug.cgi?id=155571
 

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -592,6 +592,7 @@
 localizedStrings["Response"] = "Response";
 localizedStrings["Response Headers"] = "Response Headers";
 localizedStrings["Restart (%s)"] = "Restart (%s)";
+localizedStrings["Retained Size"] = "Retained Size";
 localizedStrings["Return type for anonymous function"] = "Return type for anonymous function";
 localizedStrings["Return type for function: %s"] = "Return type for function: %s";
 localizedStrings["Reveal in DOM Tree"] = "Reveal in DOM Tree";
@@ -622,6 +623,7 @@
 localizedStrings["Selected Symbol"] = "Selected Symbol";
 localizedStrings["Selected Value"] = "Selected Value";
 localizedStrings["Self"] = "Self";
+localizedStrings["Self Size"] = "Self Size";
 localizedStrings["Self Time"] = "Self Time";
 localizedStrings["Semantic Issue"] = "Semantic Issue";
 localizedStrings["Session"] = "Session";
@@ -649,6 +651,7 @@
 localizedStrings["Show type information"] = "Show type information";
 localizedStrings["Shrink"] = "Shrink";
 localizedStrings["Size"] = "Size";
+localizedStrings["Size of the current object plus the size of all objects it keeps alive."] = "Size of the current object plus the size of all objects it keeps alive.";
 localizedStrings["Sizing"] = "Sizing";
 localizedStrings["Slice"] = "Slice";
 localizedStrings["Small %s"] = "Small %s";
@@ -722,7 +725,6 @@
 localizedStrings["Toggle Classes"] = "Toggle Classes";
 localizedStrings["Top"] = "Top";
 localizedStrings["Top Down"] = "Top Down";
-localizedStrings["Total Size"] = "Total Size";
 localizedStrings["Total Time"] = "Total Time";
 localizedStrings["Total memory size at the end of the selected time range"] = "Total memory size at the end of the selected time range";
 localizedStrings["Total number of resources, click to show the Resources tab"] = "Total number of resources, click to show the Resources tab";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -497,6 +497,9 @@
         if (column["group"])
             headerCellElement.classList.add("column-group-" + column["group"]);
 
+        if (column["tooltip"])
+            headerCellElement.title = column["tooltip"];
+
         if (column["collapsesGroup"]) {
             console.assert(column["group"] !== column["collapsesGroup"]);
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClassDataGridNode.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -44,18 +44,21 @@
 
     createCellContent(columnIdentifier)
     {
-        if (columnIdentifier === "size") {
-            let {size, percent} = this._data;
+        if (columnIdentifier === "retainedSize") {
+            let size = this._data.retainedSize;
             let fragment = document.createDocumentFragment();
-            let timeElement = fragment.appendChild(document.createElement("span"));
-            timeElement.classList.add("size");
-            timeElement.textContent = Number.bytesToString(size);
+            let sizeElement = fragment.appendChild(document.createElement("span"));
+            sizeElement.classList.add("size");
+            sizeElement.textContent = Number.bytesToString(size);
             let percentElement = fragment.appendChild(document.createElement("span"));
             percentElement.classList.add("percentage");
-            percentElement.textContent = Number.percentageString(percent);
+            percentElement.textContent = emDash;
             return fragment;
         }
 
+        if (columnIdentifier === "size")
+            return Number.bytesToString(this._data.size);
+
         if (columnIdentifier === "className") {
             let {className, allInternal} = this._data;
             let fragment = document.createDocumentFragment();
@@ -74,7 +77,7 @@
     {
         if (this._batched) {
             this._removeFetchMoreDataGridNode();
-            this._updateBatchedSort();
+            this._sortInstances();
             this._updateBatchedChildren();
             this._appendFetchMoreDataGridNode();
             return;
@@ -96,23 +99,22 @@
         this.removeEventListener("populate", this._populate, this);
 
         this._tree.heapSnapshot.instancesWithClassName(this._data.className, (instances) => {
+            this._instances = instances;
+            this._sortInstances();
+
             // Batch.
             if (instances.length > WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit) {
                 // FIXME: This should respect the this._tree.includeInternalObjects setting.
-                this._instances = instances;
                 this._batched = true;
-                this._updateBatchedSort();
                 this._fetchBatch(WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit);
                 return;
             }
 
-            for (let instance of instances) {
+            for (let instance of this._instances) {
                 if (instance.internal && !this._tree.includeInternalObjects)
                     continue;
                 this.appendChild(new WebInspector.HeapSnapshotInstanceDataGridNode(instance, this._tree));
             }
-
-            this.sort();
         });
     }
 
@@ -139,7 +141,7 @@
             this._appendFetchMoreDataGridNode();
     }
 
-    _updateBatchedSort()
+    _sortInstances()
     {
         this._instances.sort((a, b) => {
             let fakeDataGridNodeA = {data: a};

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -36,8 +36,6 @@
 
         // FIXME: Make instance grid nodes copyable.
         this.copyable = false;
-
-        this._percent = (this._node.size / this._tree._heapSnapshot.totalSize) * 100;
     }
 
     // Static
@@ -99,19 +97,22 @@
 
     createCellContent(columnIdentifier)
     {
-        if (columnIdentifier === "size") {
-            let size = this._node.size;
-            let percent = this._percent;
+        if (columnIdentifier === "retainedSize") {
+            let size = this._node.retainedSize;
             let fragment = document.createDocumentFragment();
-            let timeElement = fragment.appendChild(document.createElement("span"));
-            timeElement.classList.add("size");
-            timeElement.textContent = Number.bytesToString(size);
+            let sizeElement = fragment.appendChild(document.createElement("span"));
+            sizeElement.classList.add("size");
+            sizeElement.textContent = Number.bytesToString(size);
+            let percent = (size / this._tree._heapSnapshot.totalSize) * 100;
             let percentElement = fragment.appendChild(document.createElement("span"));
             percentElement.classList.add("percentage");
             percentElement.textContent = Number.percentageString(percent);
             return fragment;
         }
 
+        if (columnIdentifier === "size")
+            return Number.bytesToString(this._node.size);
+
         if (columnIdentifier === "className") {
             let {className, id, internal} = this._node;
             let containerElement = document.createElement("span");

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -36,15 +36,22 @@
         let {showInternalObjects} = extraArguments;
 
         let columns = {
-            size: {
-                title: WebInspector.UIString("Total Size"),
+            retainedSize: {
+                title: WebInspector.UIString("Retained Size"),
+                tooltip: WebInspector.UIString("Size of the current object plus the size of all objects it keeps alive."),
                 width: "140px",
                 aligned: "right",
+                sortable: true, 
+            },
+            size: {
+                title: WebInspector.UIString("Self Size"),
+                width: "90px",
+                aligned: "right",
                 sortable: true,
             },
             count: {
                 title: WebInspector.UIString("Count"),
-                width: "80px",
+                width: "75px",
                 aligned: "right",
                 sortable: true,
             },
@@ -56,7 +63,7 @@
         };
 
         this._dataGrid = new WebInspector.DataGrid(columns);
-        this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("heap-snapshot-content-view-sort", "size");
+        this._dataGrid.sortColumnIdentifierSetting = new WebInspector.Setting("heap-snapshot-content-view-sort", "retainedSize");
         this._dataGrid.sortOrderSetting = new WebInspector.Setting("heap-snapshot-content-view-sort-order", WebInspector.DataGrid.SortOrder.Descending);
         this._dataGrid.addEventListener(WebInspector.DataGrid.Event.SortChanged, this._sortDataGrid, this);
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesDataGridTree.js (198357 => 198358)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesDataGridTree.js	2016-03-17 22:48:41 UTC (rev 198357)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesDataGridTree.js	2016-03-17 23:25:40 UTC (rev 198358)
@@ -54,6 +54,8 @@
 
         let comparator;
         switch (columnIdentifier) {
+        case "retainedSize":
+            return numberCompare.bind(this, "retainedSize");
         case "size":
             return numberCompare.bind(this, "size");
         case "count":
@@ -158,13 +160,11 @@
         this.removeChildren();
 
         // Populate the first level with the different classes.
-        let totalSize = this._heapSnapshot.totalSize;
-        for (let [className, {size, count, internalCount}] of this._heapSnapshot.categories) {
+        for (let [className, {size, retainedSize, count, internalCount}] of this._heapSnapshot.categories) {
             let allInternal = count === internalCount;
             if (!this._includeInternalObjects && allInternal)
                 continue;
-            let percent = (size / totalSize) * 100;
-            this.appendChild(new WebInspector.HeapSnapshotClassDataGridNode({className, size, count, percent, allInternal}, this));
+            this.appendChild(new WebInspector.HeapSnapshotClassDataGridNode({className, size, retainedSize, count, allInternal}, this));
         }
     }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to