Title: [118529] trunk/Source/WebCore
- Revision
- 118529
- Author
- [email protected]
- Date
- 2012-05-25 08:40:55 -0700 (Fri, 25 May 2012)
Log Message
Web Inspector: speed-up HeapSnapshot._bfs method.
https://bugs.webkit.org/show_bug.cgi?id=87502
It had containmentEdges.length call in the loop that forced deoptimization.
Reviewed by Yury Semikhatsky.
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype._calculateObjectToWindowDistance):
(WebInspector.HeapSnapshot.prototype._bfs):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (118528 => 118529)
--- trunk/Source/WebCore/ChangeLog 2012-05-25 15:32:52 UTC (rev 118528)
+++ trunk/Source/WebCore/ChangeLog 2012-05-25 15:40:55 UTC (rev 118529)
@@ -1,3 +1,16 @@
+2012-05-25 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: speed-up HeapSnapshot._bfs method.
+ https://bugs.webkit.org/show_bug.cgi?id=87502
+
+ It had containmentEdges.length call in the loop that forced deoptimization.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/HeapSnapshot.js:
+ (WebInspector.HeapSnapshot.prototype._calculateObjectToWindowDistance):
+ (WebInspector.HeapSnapshot.prototype._bfs):
+
2012-05-25 Alexei Filippov <[email protected]>
Web Inspector: Speed up edges iteration in heap profiler
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (118528 => 118529)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-05-25 15:32:52 UTC (rev 118528)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js 2012-05-25 15:40:55 UTC (rev 118529)
@@ -888,25 +888,26 @@
var distances = new Uint32Array(this.nodeCount);
// bfs for Window roots
- var list = [];
+ var nodesToVisit = new Uint32Array(this.nodeCount);
+ var nodesToVisitLength = 0;
for (var iter = this.rootNode().edges(); iter.hasNext(); iter.next()) {
var node = iter.edge.node();
if (node.isWindow()) {
- list.push(node.nodeIndex);
+ nodesToVisit[nodesToVisitLength++] = node.nodeIndex;
distances[node.nodeIndex / nodeFieldCount] = 0;
}
}
- this._bfs(list, distances);
+ this._bfs(nodesToVisit, nodesToVisitLength, distances);
// bfs for root
- list = [];
- list.push(this._rootNodeIndex);
+ nodesToVisitLength = 0;
+ nodesToVisit[nodesToVisitLength++] = this._rootNodeIndex;
distances[this._rootNodeIndex / nodeFieldCount] = 0;
- this._bfs(list, distances);
+ this._bfs(nodesToVisit, nodesToVisitLength, distances);
this._distancesToWindow = distances;
},
- _bfs: function(list, distances)
+ _bfs: function(nodesToVisit, nodesToVisitLength, distances)
{
// Peload fields into local variables for better performance.
var edgeFieldsCount = this._edgeFieldsCount;
@@ -916,15 +917,12 @@
var edgeToNodeOffset = this._edgeToNodeOffset;
var nodes = this._nodes;
var nodeCount = this.nodeCount;
+ var containmentEdgesLength = containmentEdges.length;
var index = 0;
- while (index < list.length) {
- var nodeIndex = list[index++]; // shift generates too much garbage.
+ while (index < nodesToVisitLength) {
+ var nodeIndex = nodesToVisit[index++]; // shift generates too much garbage.
var nodeOrdinal = nodeIndex / nodeFieldCount;
- if (index > 100000) {
- list = list.slice(index);
- index = 0;
- }
var distance = distances[nodeOrdinal] + 1;
var firstEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset];
var edgesEnd = nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount];
@@ -934,9 +932,11 @@
if (distances[childNodeOrdinal])
continue;
distances[childNodeOrdinal] = distance;
- list.push(childNodeIndex);
+ nodesToVisit[nodesToVisitLength++] = childNodeIndex;
}
}
+ if (nodesToVisitLength > nodeCount)
+ throw new Error("BFS failed. Nodes to visit (" + nodesToVisitLength + ") is more than nodes count (" + nodeCount + ")");
},
_buildAggregates: function(filter)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes