Title: [174555] trunk/Websites/perf.webkit.org
Revision
174555
Author
[email protected]
Date
2014-10-09 20:45:20 -0700 (Thu, 09 Oct 2014)

Log Message

New perf dashboard UI tries to fetch commits all the time
https://bugs.webkit.org/show_bug.cgi?id=137592

Reviewed by Andreas Kling.

Added hasReportedCommits boolean to repository meta data in manifest.json, and used that in
the front end to avoid issuing HTTP requests to fetch commit logs for repositories with
no reported commits as they are all going to fail.

Also added an internal cache to FetchCommitsForTimeRange in the front end to avoid fetching
the same commit logs repeatedly. There are two data structures we cache: commitsByRevision
which maps a given commit revision/hash to a commit object; and commitsByTime which is an array
of commits sorted chronologically by time.

* public/include/manifest.php:

* public/v2/app.js:
(App.CommitsViewerComponent.commitsChanged):

* public/v2/data.js:
(FetchCommitsForTimeRange):
(FetchCommitsForTimeRange._cachedCommitsByRepository):

* public/v2/manifest.js:
(App.Repository):

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (174554 => 174555)


--- trunk/Websites/perf.webkit.org/ChangeLog	2014-10-10 03:34:01 UTC (rev 174554)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2014-10-10 03:45:20 UTC (rev 174555)
@@ -1,3 +1,31 @@
+2014-10-09  Ryosuke Niwa  <[email protected]>
+
+        New perf dashboard UI tries to fetch commits all the time
+        https://bugs.webkit.org/show_bug.cgi?id=137592
+
+        Reviewed by Andreas Kling.
+
+        Added hasReportedCommits boolean to repository meta data in manifest.json, and used that in
+        the front end to avoid issuing HTTP requests to fetch commit logs for repositories with
+        no reported commits as they are all going to fail.
+
+        Also added an internal cache to FetchCommitsForTimeRange in the front end to avoid fetching
+        the same commit logs repeatedly. There are two data structures we cache: commitsByRevision
+        which maps a given commit revision/hash to a commit object; and commitsByTime which is an array
+        of commits sorted chronologically by time.
+
+        * public/include/manifest.php:
+
+        * public/v2/app.js:
+        (App.CommitsViewerComponent.commitsChanged):
+
+        * public/v2/data.js:
+        (FetchCommitsForTimeRange):
+        (FetchCommitsForTimeRange._cachedCommitsByRepository):
+
+        * public/v2/manifest.js:
+        (App.Repository):
+
 2014-10-08  Ryosuke Niwa  <[email protected]>
 
         Another unreviewed build fix after r174477.

Modified: trunk/Websites/perf.webkit.org/public/include/manifest.php (174554 => 174555)


--- trunk/Websites/perf.webkit.org/public/include/manifest.php	2014-10-10 03:34:01 UTC (rev 174554)
+++ trunk/Websites/perf.webkit.org/public/include/manifest.php	2014-10-10 03:45:20 UTC (rev 174555)
@@ -15,12 +15,18 @@
         $config_table = $this->db->fetch_table('test_configurations');
         $platform_table = $this->db->fetch_table('platforms');
         $repositories_table = $this->db->fetch_table('repositories');
+
+        $repositories_with_commit = $this->db->query_and_fetch_all(
+            'SELECT DISTINCT(commit_repository) FROM commits WHERE commit_reported IS TRUE') or array();
+        foreach ($repositories_with_commit as &$row)
+            $row = $row['commit_repository'];
+
         $this->manifest = array(
             'tests' => $this->tests(),
             'metrics' => $this->metrics(),
             'all' => $this->platforms($config_table, $platform_table, false),
             'dashboard' => $this->platforms($config_table, $platform_table, true),
-            'repositories' => $this->repositories($repositories_table),
+            'repositories' => $this->repositories($repositories_table, $repositories_with_commit),
             'builders' => $this->builders(),
             'bugTrackers' => $this->bug_trackers($repositories_table),
         );
@@ -85,12 +91,16 @@
         return $platforms;
     }
 
-    private function repositories($repositories_table) {
+    private function repositories($repositories_table, $repositories_with_commit) {
         $repositories = array();
         if (!$repositories_table)
             return $repositories;
-        foreach ($repositories_table as $row)
-            $repositories[$row['repository_name']] = array('url' => $row['repository_url'], 'blameUrl' => $row['repository_blame_url']);
+        foreach ($repositories_table as $row) {
+            $repositories[$row['repository_name']] = array(
+                'url' => $row['repository_url'],
+                'blameUrl' => $row['repository_blame_url'],
+                'hasReportedCommits' => in_array($row['repository_id'], $repositories_with_commit));
+        }
 
         return $repositories;
     }

Modified: trunk/Websites/perf.webkit.org/public/v2/app.js (174554 => 174555)


--- trunk/Websites/perf.webkit.org/public/v2/app.js	2014-10-10 03:34:01 UTC (rev 174554)
+++ trunk/Websites/perf.webkit.org/public/v2/app.js	2014-10-10 03:45:20 UTC (rev 174555)
@@ -1408,7 +1408,7 @@
         var to = revisionInfo.get('currentRevision');
         var from = revisionInfo.get('previousRevision') || to;
         var repository = this.get('repository');
-        if (!from || !repository)
+        if (!from || !repository || !repository.get('hasReportedCommits'))
             return;
 
         var self = this;

Modified: trunk/Websites/perf.webkit.org/public/v2/data.js (174554 => 174555)


--- trunk/Websites/perf.webkit.org/public/v2/data.js	2014-10-10 03:34:01 UTC (rev 174554)
+++ trunk/Websites/perf.webkit.org/public/v2/data.js	2014-10-10 03:45:20 UTC (rev 174555)
@@ -1,15 +1,44 @@
 // We don't use DS.Model for these object types because we can't afford to process millions of them.
 
-FetchCommitsForTimeRange = function (repository, from, to)
+function FetchCommitsForTimeRange(repository, from, to)
 {
     var url = '' + repository.get('id') + '/' + from + '-' + to;
-    console.log('Fetching ' + url)
+
+    var cachedCommits = FetchCommitsForTimeRange._cachedCommitsByRepository[repository];
+    if (!cachedCommits) {
+        cachedCommits = {commitsByRevision: {}, commitsByTime: []};
+        FetchCommitsForTimeRange._cachedCommitsByRepository[repository] = cachedCommits;
+    }
+
+    if (cachedCommits) {
+        var startCommit = cachedCommits.commitsByRevision[from];
+        var endCommit = cachedCommits.commitsByRevision[to];
+        if (startCommit && endCommit) {
+            return new Ember.RSVP.Promise(function (resolve) {
+                resolve(cachedCommits.commitsByTime.slice(startCommit.index, endCommit.index + 1)) });
+        }
+    }
+
+    console.log('Fecthing ' + url);
+
     return new Ember.RSVP.Promise(function (resolve, reject) {
         $.getJSON(url, function (data) {
             if (data.status != 'OK') {
                 reject(data.status);
                 return;
             }
+
+            data.commits.forEach(function (commit) {
+                if (cachedCommits.commitsByRevision[commit.revision])
+                    return;
+                commit.time = new Date(commit.time.replace(' ', 'T'));
+                cachedCommits.commitsByRevision[commit.revision] = commit;
+                cachedCommits.commitsByTime.push(commit);
+            });
+
+            cachedCommits.commitsByTime.sort(function (a, b) { return a.time - b.time; });
+            cachedCommits.commitsByTime.forEach(function (commit, index) { commit.index = index; });
+
             resolve(data.commits);
         }).fail(function (xhr, status, error) {
             reject(xhr.status + (error ? ', ' + error : ''));
@@ -17,6 +46,8 @@
     });
 }
 
+FetchCommitsForTimeRange._cachedCommitsByRepository = {};
+
 function Measurement(rawData)
 {
     this._raw = rawData;

Modified: trunk/Websites/perf.webkit.org/public/v2/manifest.js (174554 => 174555)


--- trunk/Websites/perf.webkit.org/public/v2/manifest.js	2014-10-10 03:34:01 UTC (rev 174554)
+++ trunk/Websites/perf.webkit.org/public/v2/manifest.js	2014-10-10 03:45:20 UTC (rev 174555)
@@ -72,6 +72,7 @@
 App.Repository = App.NameLabelModel.extend({
     url: DS.attr('string'),
     blameUrl: DS.attr('string'),
+    hasReportedCommits: DS.attr('boolean'),
     urlForRevision: function (currentRevision) {
         return (this.get('url') || '').replace(/\$1/g, currentRevision);
     },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to