Title: [212729] trunk/Tools
Revision
212729
Author
[email protected]
Date
2017-02-21 11:11:27 -0800 (Tue, 21 Feb 2017)

Log Message

Improve bot watcher's dashboard performance
https://bugs.webkit.org/show_bug.cgi?id=168624
<rdar://problem/30190109>

Reviewed by Daniel Bates.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
There was an unnecessary linear complexity algorithm in indexOfRevision().

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js (212728 => 212729)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2017-02-21 19:07:17 UTC (rev 212728)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2017-02-21 19:11:27 UTC (rev 212729)
@@ -37,6 +37,7 @@
     }
 
     this.recordedCommits = []; // Will be sorted in ascending order.
+    this.recordedCommitIndicesByRevisionNumber = {};
 };
 
 BaseObject.addConstructorFunctions(Trac);
@@ -223,11 +224,6 @@
         if (!dataDocument)
             return;
 
-        var recordedRevisionNumbers = this.recordedCommits.reduce(function(previousResult, commit) {
-            previousResult[commit.revisionNumber] = commit;
-            return previousResult;
-        }, {});
-
         var knownCommitsWereUpdated = false;
         var newCommits = [];
 
@@ -235,11 +231,12 @@
         var commitInfoElement;
         while (commitInfoElement = commitInfoElements.iterateNext()) {
             var commit = this._convertCommitInfoElementToObject(dataDocument, commitInfoElement);
-            if (commit.revisionNumber in recordedRevisionNumbers) {
+            var knownCommitIndex = this.recordedCommitIndicesByRevisionNumber[commit.revisionNumber];
+            if (knownCommitIndex >= 0) {
                 // Author could have changed, as commit queue replaces it after the fact.
-                console.assert(recordedRevisionNumbers[commit.revisionNumber].revisionNumber === commit.revisionNumber);
-                if (recordedRevisionNumbers[commit.revisionNumber].author != commit.author) {
-                    recordedRevisionNumbers[commit.revisionNumber].author = commit.author;
+                console.assert(this.recordedCommits[knownCommitIndex].revisionNumber === commit.revisionNumber);
+                if (this.recordedCommits[knownCommitIndex].author != commit.author) {
+                    this.recordedCommits[knownCommitIndex].author = commit.author;
                     knownCommitWasUpdated = true;
                 }
             } else
@@ -246,8 +243,13 @@
                 newCommits.push(commit);
         }
 
-        if (newCommits.length)
+        if (newCommits.length) {
             this.recordedCommits = newCommits.concat(this.recordedCommits).sort(function(a, b) { return a.date - b.date; });
+            this.recordedCommitIndicesByRevisionNumber = {};
+            this.recordedCommits.forEach(function(curentValue, index) {
+                this.recordedCommitIndicesByRevisionNumber[curentValue.revisionNumber] = index;
+            }, this);
+        }
 
         if (newCommits.length || knownCommitsWereUpdated)
             this.dispatchEventToListeners(Trac.Event.CommitsUpdated, null);
@@ -318,13 +320,12 @@
         return Trac.NO_MORE_REVISIONS;
     },
 
-    indexOfRevision: function(revision)
+    indexOfRevision: function(revisionNumber)
     {
-        var commits = this.recordedCommits;
-        for (var i = 0; i < commits.length; ++i) {
-            if (commits[i].revisionNumber === revision)
-                return i;
-        }
-        return -1;
+        var result = this.recordedCommitIndicesByRevisionNumber[revisionNumber];
+        // FIXME: Update callers to handle undefined result.
+        if (result === undefined)
+            return -1;
+        return result;
     },
 };

Modified: trunk/Tools/ChangeLog (212728 => 212729)


--- trunk/Tools/ChangeLog	2017-02-21 19:07:17 UTC (rev 212728)
+++ trunk/Tools/ChangeLog	2017-02-21 19:11:27 UTC (rev 212729)
@@ -1,3 +1,14 @@
+2017-02-21  Alexey Proskuryakov  <[email protected]>
+
+        Improve bot watcher's dashboard performance
+        https://bugs.webkit.org/show_bug.cgi?id=168624
+        <rdar://problem/30190109>
+
+        Reviewed by Daniel Bates.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
+        There was an unnecessary linear complexity algorithm in indexOfRevision().
+
 2017-02-21  Alex Christensen  <[email protected]>
 
         Unreviewed, rolling out r212699.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to