Changeset 112540 in webkit


Ignore:
Timestamp:
Mar 29, 2012 9:25:24 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: check more likely condition first in HeapSnapshot._buildAggregates
https://bugs.webkit.org/show_bug.cgi?id=82621

Reviewed by Pavel Feldman.

  • inspector/front-end/HeapSnapshot.js: selfSize === 0 is quite rare, moving this condition

to the first place saves 1 of 6 secs on the heap profiler perf test.
(WebInspector.HeapSnapshot.prototype._buildAggregates):
(WebInspector.HeapSnapshot.prototype._buildDominatedNodes): root node is always the first
one and is the only one that doesn't have dominator, so we may start iterating nodes from
the second node and avoid additional check in the loop.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112539 r112540  
     12012-03-29  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: check more likely condition first in HeapSnapshot._buildAggregates
     4        https://bugs.webkit.org/show_bug.cgi?id=82621
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/front-end/HeapSnapshot.js: selfSize === 0 is quite rare, moving this condition
     9        to the first place saves 1 of 6 secs on the heap profiler perf test.
     10        (WebInspector.HeapSnapshot.prototype._buildAggregates):
     11        (WebInspector.HeapSnapshot.prototype._buildDominatedNodes): root node is always the first
     12        one and is the only one that doesn't have dominator, so we may start iterating nodes from
     13        the second node and avoid additional check in the loop.
     14
    1152012-03-29  Pavel Feldman  <pfeldman@chromium.org>
    216
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r112523 r112540  
    10921092            if (filter && !filter(node))
    10931093                return true;
    1094             if (!node.isNative && node.selfSize === 0)
     1094            if (!node.selfSize && !node.isNative)
    10951095                return true;
    10961096            return false;
     
    11771177        var dominatedNodes = this._dominatedNodes = new Uint32Array(this.nodeCount - 1);
    11781178
    1179         // Count the number of dominated nodes for each node
    1180         for (var nodeIndex = 0; nodeIndex < this._onlyNodes.length; nodeIndex += this._nodeFieldCount) {
     1179        // Count the number of dominated nodes for each node. Skip the root (node at
     1180        // index 0) as it is the only node that dominates itself.
     1181        for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._onlyNodes.length; nodeIndex += this._nodeFieldCount) {
    11811182            var dominatorIndex = this._onlyNodes[nodeIndex + this._dominatorOffset];
    11821183            if (dominatorIndex % this._nodeFieldCount)
    11831184                throw new Error("Wrong dominatorIndex " + dominatorIndex + " nodeIndex = " + nodeIndex + " nodeCount = " + this.nodeCount);
    1184             // Skip root node. We may simplify this by starting iteration from second node.
    1185             if (nodeIndex === dominatorIndex) continue;
    11861185            ++indexArray[dominatorIndex / this._nodeFieldCount];
    11871186        }
     
    11891188        // that will be filled.
    11901189        var firstDominatedNodeIndex = 0;
    1191         for (i = 0; i <= this.nodeCount; ++i) {
     1190        for (i = 0; i < this.nodeCount; ++i) {
    11921191            var dominatedCount = dominatedNodes[firstDominatedNodeIndex] = indexArray[i];
    11931192            indexArray[i] = firstDominatedNodeIndex;
    11941193            firstDominatedNodeIndex += dominatedCount;
    11951194        }
    1196         // Fill up the dominatedNodes array with indexes of dominated nodes.
    1197         for (var nodeIndex = 0; nodeIndex < this._onlyNodes.length; nodeIndex += this._nodeFieldCount) {
     1195        indexArray[this.nodeCount] = dominatedNodes.length;
     1196        // Fill up the dominatedNodes array with indexes of dominated nodes. Skip the root (node at
     1197        // index 0) as it is the only node that dominates itself.
     1198        for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._onlyNodes.length; nodeIndex += this._nodeFieldCount) {
    11981199            var dominatorIndex = this._onlyNodes[nodeIndex + this._dominatorOffset];
    11991200            if (dominatorIndex % this._nodeFieldCount)
    12001201                throw new Error("Wrong dominatorIndex " + dominatorIndex);
    1201             if (nodeIndex === dominatorIndex) continue;
    12021202            var dominatorPos = dominatorIndex / this._nodeFieldCount;
    12031203            var dominatedRefIndex = indexArray[dominatorPos];
Note: See TracChangeset for help on using the changeset viewer.