Web Inspector: Detailed heap snapshot. _calculateFlags is too slow on a large heap...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2012 11:36:38 +0000 (11:36 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jan 2012 11:36:38 +0000 (11:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76252

_calculateFlags speed is about 10k edges per second.
It requires 150sec for the snapshot with 1.5m edges.
The root of problem is var node = list.shift();
shift() is not effective in term of memory and cpu.
In our case it can be replaced with pop().
Now the function works 40 times faster.

Drive by change: if statement was reformatted a bit for better readability.

Reviewed by Yury Semikhatsky.

* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype._calculateFlags):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104916 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HeapSnapshot.js

index 337766fb99b1e3df03de30ac95deea90c32151cb..5e4587a1e3e62613ce81c0c4ea02128260b34b54 100644 (file)
@@ -1,3 +1,22 @@
+2012-01-13  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: Detailed heap snapshot. _calculateFlags is too slow on a large heap snapshot.
+        https://bugs.webkit.org/show_bug.cgi?id=76252
+
+        _calculateFlags speed is about 10k edges per second.
+        It requires 150sec for the snapshot with 1.5m edges.
+        The root of problem is var node = list.shift();
+        shift() is not effective in term of memory and cpu.
+        In our case it can be replaced with pop().
+        Now the function works 40 times faster.
+
+        Drive by change: if statement was reformatted a bit for better readability.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshot.prototype._calculateFlags):
+
 2012-01-13  Alexander Pavlov  <apavlov@chromium.org>
 
         Web Inspector: [Chromium] JavaScriptOutlineDialog fails to open
index 69f4ec0e1ca3605ac6cd5947249c014157c5ccea..a7880eb64c4fc4610caeb777da6c188a77017cb8 100644 (file)
@@ -1045,16 +1045,25 @@ WebInspector.HeapSnapshot.prototype = {
             if (iter.edge.node.isDOMWindow)
                 list.push(iter.edge.node);
         }
+
         while (list.length) {
-            var node = list.shift();
-            if (node.canBeQueried) continue;
+            var node = list.pop();
+            if (this._flags[node.nodeIndex])
+                continue;
             this._flags[node.nodeIndex] = flag;
             for (var iter = node.edges; iter.hasNext(); iter.next()) {
                 var edge = iter.edge;
-                if (!edge.isHidden && !edge.isInvisible &&
-                    edge.name && (!edge.isInternal || edge.name === "native") &&
-                    !edge.node.canBeQueried)
-                    list.push(edge.node);
+                var node = edge.node;
+                if (this._flags[node.nodeIndex])
+                    continue;
+                if (edge.isHidden || edge.isInvisible)
+                    continue;
+                var name = edge.name;
+                if (!name)
+                    continue;
+                if (edge.isInternal && name !== "native")
+                    continue;
+                list.push(node);
             }
         }
     },