- Revision
- 118528
- Author
- [email protected]
- Date
- 2012-05-25 08:32:52 -0700 (Fri, 25 May 2012)
Log Message
Web Inspector: Speed up edges iteration in heap profiler
https://bugs.webkit.org/show_bug.cgi?id=87286
Add an extra node to nodes array that points to the end of edges array.
It allows to eliminate a check for the last node in iteration code.
Patch by Alexei Filippov <[email protected]> on 2012-05-25
Reviewed by Yury Semikhatsky.
Source/WebCore:
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshotNode.prototype._edgeIndexesStart):
(WebInspector.HeapSnapshotNode.prototype._edgeIndexesEnd):
(WebInspector.HeapSnapshotNodeIterator):
(WebInspector.HeapSnapshot.prototype._buildRetainers):
(WebInspector.HeapSnapshot.prototype._bfs):
(WebInspector.HeapSnapshot.prototype._buildAggregates):
(WebInspector.HeapSnapshot.prototype._buildPostOrderIndex):
(WebInspector.HeapSnapshot.prototype._buildDominatorTree):
(WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
LayoutTests:
* inspector/profiler/heap-snapshot-test.js:
(initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockObject):
(initialize_HeapSnapshotTest.InspectorTest._postprocessHeapSnapshotMock):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (118527 => 118528)
--- trunk/LayoutTests/ChangeLog 2012-05-25 15:16:36 UTC (rev 118527)
+++ trunk/LayoutTests/ChangeLog 2012-05-25 15:32:52 UTC (rev 118528)
@@ -1,3 +1,17 @@
+2012-05-25 Alexei Filippov <[email protected]>
+
+ Web Inspector: Speed up edges iteration in heap profiler
+ https://bugs.webkit.org/show_bug.cgi?id=87286
+
+ Add an extra node to nodes array that points to the end of edges array.
+ It allows to eliminate a check for the last node in iteration code.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/profiler/heap-snapshot-test.js:
+ (initialize_HeapSnapshotTest.InspectorTest.createHeapSnapshotMockObject):
+ (initialize_HeapSnapshotTest.InspectorTest._postprocessHeapSnapshotMock):
+
2012-05-25 Zan Dobersek <[email protected]>
Unreviewed GTK gardening after r118166, r118291 and r118442.
Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js (118527 => 118528)
--- trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-05-25 15:16:36 UTC (rev 118527)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-05-25 15:32:52 UTC (rev 118528)
@@ -19,6 +19,7 @@
_edgeShortcutType: -1,
_edgeHiddenType: -1,
_edgeElementType: 0,
+ _realNodesLength: 18,
// Represents the following graph:
// (numbers in parentheses indicate node offset)
//
@@ -34,7 +35,8 @@
1, 2, 12, // 6: B
1, 3, 18, // 9: C
1, 4, 21, // 12: D
- 1, 5, 21], // 15: E
+ 1, 5, 21, // 15: E
+ 0, 0, 21], // 18: (extra node)
_containmentEdges: [
2, 6, 3, // 0: shortcut 'a' to node 'A'
1, 7, 6, // 3: property 'b' to node 'B'
@@ -99,8 +101,8 @@
InspectorTest._postprocessHeapSnapshotMock = function(mock)
{
- mock.nodes = new Int32Array(mock.nodes);
- mock.edges = new Int32Array(mock.edges);
+ mock.nodes = new Uint32Array(mock.nodes);
+ mock.edges = new Uint32Array(mock.edges);
return mock;
};
Modified: trunk/Source/WebCore/ChangeLog (118527 => 118528)
--- trunk/Source/WebCore/ChangeLog 2012-05-25 15:16:36 UTC (rev 118527)
+++ trunk/Source/WebCore/ChangeLog 2012-05-25 15:32:52 UTC (rev 118528)
@@ -1,3 +1,24 @@
+2012-05-25 Alexei Filippov <[email protected]>
+
+ Web Inspector: Speed up edges iteration in heap profiler
+ https://bugs.webkit.org/show_bug.cgi?id=87286
+
+ Add an extra node to nodes array that points to the end of edges array.
+ It allows to eliminate a check for the last node in iteration code.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/HeapSnapshot.js:
+ (WebInspector.HeapSnapshotNode.prototype._edgeIndexesStart):
+ (WebInspector.HeapSnapshotNode.prototype._edgeIndexesEnd):
+ (WebInspector.HeapSnapshotNodeIterator):
+ (WebInspector.HeapSnapshot.prototype._buildRetainers):
+ (WebInspector.HeapSnapshot.prototype._bfs):
+ (WebInspector.HeapSnapshot.prototype._buildAggregates):
+ (WebInspector.HeapSnapshot.prototype._buildPostOrderIndex):
+ (WebInspector.HeapSnapshot.prototype._buildDominatorTree):
+ (WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
+
2012-05-25 Andrey Kosyakov <[email protected]>
Web Inspector: put paint and compositing timeline events in a new category of their own
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (118527 => 118528)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-05-25 15:16:36 UTC (rev 118527)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-05-25 15:32:52 UTC (rev 118528)
@@ -535,16 +535,14 @@
_edgeIndexesStart: function()
{
- return this._snapshot._nodes[this.nodeIndex + this._snapshot._firstEdgeIndexOffset];
+ var snapshot = this._snapshot;
+ return snapshot._nodes[this.nodeIndex + snapshot._firstEdgeIndexOffset];
},
_edgeIndexesEnd: function()
{
- var nextNodeIndex = this._nextNodeIndex();
var snapshot = this._snapshot;
- if (nextNodeIndex < snapshot._nodes.length)
- return snapshot._nodes[nextNodeIndex + snapshot._firstEdgeIndexOffset]
- return snapshot._containmentEdges.length;
+ return snapshot._nodes[this._nextNodeIndex() + snapshot._firstEdgeIndexOffset]
},
_nextNodeIndex: function()
@@ -565,7 +563,7 @@
WebInspector.HeapSnapshotNodeIterator = function(node)
{
this.node = node;
- this._nodesLength = node._snapshot._nodes.length;
+ this._nodesLength = node._snapshot._realNodesLength;
}
WebInspector.HeapSnapshotNodeIterator.prototype = {
@@ -690,9 +688,16 @@
visitedMarker: 0x10000 // bits: 1,0000,0000,0000,0000
};
- this.nodeCount = this._nodes.length / this._nodeFieldCount;
+ this._realNodesLength = this._nodes.length;
+ this.nodeCount = this._realNodesLength / this._nodeFieldCount;
this._edgeCount = this._containmentEdges.length / this._edgeFieldsCount;
+ // Add an extra node and make its first edge field point to the end of edges array.
+ var nodes = this._nodes;
+ this._nodes = new Uint32Array(this._realNodesLength + this._nodeFieldCount);
+ this._nodes.set(nodes);
+ this._nodes[this._realNodesLength + this._firstEdgeIndexOffset] = this._containmentEdges.length;
+
this._markInvisibleEdges();
this._buildRetainers();
this._calculateFlags();
@@ -735,13 +740,11 @@
var srcNodeIndex = 0;
var nextNodeFirstEdgeIndex = nodes[firstEdgeIndexOffset];
- var nodesLength = nodes.length;
+ var nodesLength = this._realNodesLength;
while (srcNodeIndex < nodesLength) {
var firstEdgeIndex = nextNodeFirstEdgeIndex;
var nextNodeIndex = srcNodeIndex + nodeFieldCount;
- nextNodeFirstEdgeIndex = nextNodeIndex < nodesLength
- ? nodes[nextNodeIndex + firstEdgeIndexOffset]
- : containmentEdges.length;
+ nextNodeFirstEdgeIndex = nodes[nextNodeIndex + firstEdgeIndexOffset];
for (var edgeIndex = firstEdgeIndex; edgeIndex < nextNodeFirstEdgeIndex; edgeIndex += edgeFieldsCount) {
var toNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
if (toNodeIndex % nodeFieldCount)
@@ -924,9 +927,7 @@
}
var distance = distances[nodeOrdinal] + 1;
var firstEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset];
- var edgesEnd = nodeOrdinal < nodeCount - 1
- ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount]
- : containmentEdges.length;
+ var edgesEnd = nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount];
for (var edgeToNodeIndex = firstEdgeIndex + edgeToNodeOffset; edgeToNodeIndex < edgesEnd; edgeToNodeIndex += edgeFieldsCount) {
var childNodeIndex = containmentEdges[edgeToNodeIndex];
var childNodeOrdinal = childNodeIndex / nodeFieldCount;
@@ -945,7 +946,7 @@
var classIndexes = [];
var nodes = this._nodes;
var flags = this._flags;
- var nodesLength = nodes.length;
+ var nodesLength = this._realNodesLength;
var nodeNativeType = this._nodeNativeType;
var nodeFieldCount = this._nodeFieldCount;
var selfSizeOffset = this._nodeSelfSizeOffset;
@@ -1097,9 +1098,7 @@
painted[nodeOrdinal] = black;
var nodeFlag = flags[nodeOrdinal] & flag;
var beginEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset];
- var endEdgeIndex = nodeOrdinal < nodeCount - 1
- ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount]
- : containmentEdgesLength;
+ var endEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount];
for (var edgeIndex = beginEdgeIndex; edgeIndex < endEdgeIndex; edgeIndex += edgeFieldsCount) {
if (nodeIndex !== rootNodeIndex && containmentEdges[edgeIndex + edgeTypeOffset] === edgeShortcutType)
continue;
@@ -1230,9 +1229,7 @@
nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
nodeIndex = nodeOrdinal * nodeFieldCount;
beginEdgeToNodeFieldIndex = nodes[nodeIndex + firstEdgeIndexOffset] + edgeToNodeOffset;
- endEdgeToNodeFieldIndex = nodeOrdinal < nodesCount - 1
- ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount]
- : containmentEdgesLength;
+ endEdgeToNodeFieldIndex = nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount];
for (var toNodeFieldIndex = beginEdgeToNodeFieldIndex;
toNodeFieldIndex < endEdgeToNodeFieldIndex;
toNodeFieldIndex += edgeFieldsCount) {
@@ -1458,9 +1455,7 @@
continue;
flags[nodeOrdinal] |= flag;
var beginEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset];
- var endEdgeIndex = nodeOrdinal < nodeCount - 1
- ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount]
- : containmentEdges.length;
+ var endEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount];
for (var edgeIndex = beginEdgeIndex; edgeIndex < endEdgeIndex; edgeIndex += edgeFieldsCount) {
var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
if (flags[childNodeIndex / nodeFieldCount] & flag)