Changeset 117437 in webkit
- Timestamp:
- May 17, 2012 5:48:07 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117432 r117437 1 2012-05-17 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: HeapSnapshot: speed-up calculateObjectToWindowDistance 4 https://bugs.webkit.org/show_bug.cgi?id=86718 5 6 The idea is to switch from nodeIndex2distance array to nodeOrdinal2distance external array. 7 Due to nature of nodeIndex values the original array was sparsed. 8 9 Reviewed by Yury Semikhatsky. 10 11 * inspector/front-end/HeapSnapshot.js: 12 (WebInspector.HeapSnapshotNode.prototype.get distanceToWindow): 13 (WebInspector.HeapSnapshot.prototype._calculateObjectToWindowDistance): 14 (WebInspector.HeapSnapshot.prototype._bfs): 15 (WebInspector.HeapSnapshot.prototype._buildAggregates): 16 1 17 2012-05-11 Kinuko Yasuda <kinuko@chromium.org> 2 18 -
trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js
r117296 r117437 427 427 get distanceToWindow() 428 428 { 429 return this._snapshot._distancesToWindow[this.nodeIndex ];429 return this._snapshot._distancesToWindow[this.nodeIndex / this._snapshot._nodeFieldCount]; 430 430 }, 431 431 … … 896 896 _calculateObjectToWindowDistance: function() 897 897 { 898 this._distancesToWindow = new Array(this.nodeCount); 898 var nodeFieldCount = this._nodeFieldCount; 899 var distances = new Uint32Array(this.nodeCount); 899 900 900 901 // bfs for Window roots … … 903 904 var node = iter.edge.node; 904 905 if (node.isWindow) { 905 if (node.nodeIndex % this._nodeFieldCount)906 throw new Error("Invalid nodeIndex: " + node.nodeIndex);907 906 list.push(node.nodeIndex); 908 this._distancesToWindow[node.nodeIndex] = 0;909 } 910 } 911 this._bfs(list );907 distances[node.nodeIndex / nodeFieldCount] = 0; 908 } 909 } 910 this._bfs(list, distances); 912 911 913 912 // bfs for root 914 913 list = []; 915 914 list.push(this._rootNodeIndex); 916 this._distancesToWindow[this._rootNodeIndex] = 0; 917 this._bfs(list); 918 }, 919 920 _bfs: function(list) 915 distances[this._rootNodeIndex / nodeFieldCount] = 0; 916 this._bfs(list, distances); 917 this._distancesToWindow = distances; 918 }, 919 920 _bfs: function(list, distances) 921 921 { 922 922 // Peload fields into local variables for better performance. … … 926 926 var firstEdgeIndexOffset = this._firstEdgeIndexOffset; 927 927 var edgeToNodeOffset = this._edgeToNodeOffset; 928 var distancesToWindow = this._distancesToWindow;929 928 var nodes = this._nodes; 929 var nodeCount = this.nodeCount; 930 930 931 931 var index = 0; 932 932 while (index < list.length) { 933 933 var nodeIndex = list[index++]; // shift generates too much garbage. 934 var nodeOrdinal = nodeIndex / nodeFieldCount; 934 935 if (index > 100000) { 935 936 list = list.slice(index); 936 937 index = 0; 937 938 } 938 var distance = distancesToWindow[nodeIndex] + 1; 939 939 var distance = distances[nodeOrdinal] + 1; 940 940 var firstEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset]; 941 var edgesEnd = node Index < nodes.length942 ? nodes[nodeIndex + nodeFieldCount + firstEdgeIndexOffset]941 var edgesEnd = nodeOrdinal < nodeCount - 1 942 ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount] 943 943 : containmentEdges.length; 944 944 for (var edgeToNodeIndex = firstEdgeIndex + edgeToNodeOffset; edgeToNodeIndex < edgesEnd; edgeToNodeIndex += edgeFieldsCount) { 945 945 var childNodeIndex = containmentEdges[edgeToNodeIndex]; 946 if (childNodeIndex % nodeFieldCount) 947 throw new Error("Invalid childNodeIndex: " + childNodeIndex); 948 if (childNodeIndex in distancesToWindow) 946 var childNodeOrdinal = childNodeIndex / nodeFieldCount; 947 if (distances[childNodeOrdinal]) 949 948 continue; 950 distances ToWindow[childNodeIndex] = distance;949 distances[childNodeOrdinal] = distance; 951 950 list.push(childNodeIndex); 952 951 } … … 968 967 969 968 for (var nodeIndex = this._rootNodeIndex; nodeIndex < nodesLength; nodeIndex += nodeFieldsCount) { 969 var nodeOrdinal = nodeIndex / nodeFieldsCount; 970 970 node.nodeIndex = nodeIndex; 971 971 var selfSize = nodes[nodeIndex + selfSizeOffset]; … … 980 980 var value = { 981 981 count: 1, 982 distanceToWindow: distancesToWindow[node Index],982 distanceToWindow: distancesToWindow[nodeOrdinal], 983 983 self: selfSize, 984 984 maxRet: 0, … … 991 991 } else { 992 992 var clss = aggregates[classIndex]; 993 clss.distanceToWindow = Math.min(clss.distanceToWindow, distancesToWindow[node Index]);993 clss.distanceToWindow = Math.min(clss.distanceToWindow, distancesToWindow[nodeOrdinal]); 994 994 ++clss.count; 995 995 clss.self += selfSize;
Note: See TracChangeset
for help on using the changeset viewer.