<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[192716] trunk/Websites/perf.webkit.org</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/192716">192716</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-11-20 19:12:14 -0800 (Fri, 20 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Perf dashboard's should not include results more than 366 days old in JSON
https://bugs.webkit.org/show_bug.cgi?id=151529

Reviewed by Timothy Hatcher.

Don't return results more than 366 days old in /api/runs/ JSON API.
This is a ~5% runtime improvement and reduces the JSON file size by 20-50% in the internal perf dashboard.

* public/api/runs.php:
(main): Added the support for &quot;?noResults&quot; to avoid echoing results. This is useful for debugging.
Also instantiate RunsGenerator before issuing the query to find all configurations so that the runtime cost
of doing so will be included in elapsedTime.
(RunsGenerator::fetch_runs): Skip a row when its build and commit times are more than 366 days old.
(RunsGenerator::format_run): Takes build_time and revisions as arguments since fetch_runs uses them now.
(RunsGenerator::parse_revisions_array): Compute the max of commit times.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicapirunsphp">trunk/Websites/perf.webkit.org/public/api/runs.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (192715 => 192716)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2015-11-21 03:05:50 UTC (rev 192715)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2015-11-21 03:12:14 UTC (rev 192716)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2015-11-20  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Perf dashboard's should not include results more than 366 days old in JSON
+        https://bugs.webkit.org/show_bug.cgi?id=151529
+
+        Reviewed by Timothy Hatcher.
+
+        Don't return results more than 366 days old in /api/runs/ JSON API.
+        This is a ~5% runtime improvement and reduces the JSON file size by 20-50% in the internal perf dashboard.
+
+        * public/api/runs.php:
+        (main): Added the support for &quot;?noResults&quot; to avoid echoing results. This is useful for debugging.
+        Also instantiate RunsGenerator before issuing the query to find all configurations so that the runtime cost
+        of doing so will be included in elapsedTime.
+        (RunsGenerator::fetch_runs): Skip a row when its build and commit times are more than 366 days old.
+        (RunsGenerator::format_run): Takes build_time and revisions as arguments since fetch_runs uses them now.
+        (RunsGenerator::parse_revisions_array): Compute the max of commit times.
+
+2015-11-20  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
</ins><span class="cx">         Remove chartPointRadius from interactive chart component
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=151480
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicapirunsphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/api/runs.php (192715 => 192716)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/api/runs.php        2015-11-21 03:05:50 UTC (rev 192715)
+++ trunk/Websites/perf.webkit.org/public/api/runs.php        2015-11-21 03:12:14 UTC (rev 192716)
</span><span class="lines">@@ -10,10 +10,19 @@
</span><span class="cx">     if (count($parts) != 2)
</span><span class="cx">         exit_with_error('InvalidRequest');
</span><span class="cx"> 
</span><ins>+    $test_group_id = array_get($_GET, 'testGroup');
+    $should_cache = array_get($_GET, 'cache');
+    $should_echo_results = !array_key_exists('noResult', $_GET);
+
</ins><span class="cx">     $db = new Database;
</span><span class="cx">     if (!$db-&gt;connect())
</span><span class="cx">         exit_with_error('DatabaseConnectionFailure');
</span><span class="cx"> 
</span><ins>+    if ($test_group_id)
+        $generator = new RunsGeneratorForTestGroup($db, $test_group_id);
+    else
+        $generator = new RunsGenerator($db);
+
</ins><span class="cx">     $platform_id = intval($parts[0]);
</span><span class="cx">     $metric_id = intval($parts[1]);
</span><span class="cx">     $config_rows = $db-&gt;query_and_fetch_all('SELECT *
</span><span class="lines">@@ -21,8 +30,6 @@
</span><span class="cx">     if (!$config_rows)
</span><span class="cx">         exit_with_error('ConfigurationNotFound');
</span><span class="cx"> 
</span><del>-    $test_group_id = array_get($_GET, 'testGroup');
-    $should_cache = array_get($_GET, 'cache');
</del><span class="cx">     if ($test_group_id)
</span><span class="cx">         $test_group_id = intval($test_group_id);
</span><span class="cx">     else if ($should_cache) { // Only v1 UI needs caching.
</span><span class="lines">@@ -31,15 +38,15 @@
</span><span class="cx">         header(&quot;Cache-Control: maxage=$maxage&quot;);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if ($test_group_id)
-        $generator = new RunsGeneratorForTestGroup($db, $test_group_id);
-    else
-        $generator = new RunsGenerator($db);
-
</del><span class="cx">     foreach ($config_rows as $config)
</span><span class="cx">         $generator-&gt;fetch_runs($config['config_type'], $config['config_id'], $config['config_runs_last_modified']);
</span><span class="cx"> 
</span><span class="cx">     $content = success_json($generator-&gt;results());
</span><ins>+    if (!$should_echo_results) {
+        echo $generator-&gt;results()['elapsedTime'];
+        return;
+    }
+
</ins><span class="cx">     if (!$test_group_id)
</span><span class="cx">         generate_data_file(&quot;$platform_id-$metric_id.json&quot;, $content);
</span><span class="cx">     echo $content;
</span><span class="lines">@@ -63,11 +70,19 @@
</span><span class="cx">     function fetch_runs($name, $config_id, $last_modified) {
</span><span class="cx">         $this-&gt;last_modified = max($this-&gt;last_modified, Database::to_js_time($last_modified));
</span><span class="cx"> 
</span><ins>+        $beginning_of_time = intval(time() - 366 * 24 * 3600) * 1000;
+
</ins><span class="cx">         $results = $this-&gt;execute_query($config_id);
</span><span class="cx"> 
</span><span class="cx">         $formatted_runs = array();
</span><del>-        while ($row = $this-&gt;db-&gt;fetch_next_row($results))
-            array_push($formatted_runs, self::format_run($row));
</del><ins>+        while ($row = $this-&gt;db-&gt;fetch_next_row($results)) {
+            $build_time = Database::to_js_time($row['build_time']);
+            $max_time = $build_time;
+            $revisions = self::parse_revisions_array($row['revisions'], $max_time);
+            if ($max_time &lt; $beginning_of_time)
+                continue;
+            array_push($formatted_runs, self::format_run($row, $build_time, $revisions));
+        }
</ins><span class="cx"> 
</span><span class="cx">         $this-&gt;results[$name] = $formatted_runs;
</span><span class="cx">     }
</span><span class="lines">@@ -82,7 +97,7 @@
</span><span class="cx">                 GROUP BY build_id, run_id', array($config_id));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    private static function format_run($run) {
</del><ins>+    private static function format_run($run, $build_time, $revisions) {
</ins><span class="cx">         return array(
</span><span class="cx">             'id' =&gt; intval($run['run_id']),
</span><span class="cx">             'mean' =&gt; floatval($run['run_mean_cache']),
</span><span class="lines">@@ -90,14 +105,14 @@
</span><span class="cx">             'sum' =&gt; floatval($run['run_sum_cache']),
</span><span class="cx">             'squareSum' =&gt; floatval($run['run_square_sum_cache']),
</span><span class="cx">             'markedOutlier' =&gt; Database::is_true($run['run_marked_outlier']),
</span><del>-            'revisions' =&gt; self::parse_revisions_array($run['revisions']),
</del><ins>+            'revisions' =&gt; $revisions,
</ins><span class="cx">             'build' =&gt; $run['build_id'],
</span><del>-            'buildTime' =&gt; Database::to_js_time($run['build_time']),
</del><ins>+            'buildTime' =&gt; $build_time,
</ins><span class="cx">             'buildNumber' =&gt; intval($run['build_number']),
</span><span class="cx">             'builder' =&gt; $run['build_builder']);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    private static function parse_revisions_array($postgres_array) {
</del><ins>+    private static function parse_revisions_array($postgres_array, &amp;$max_time) {
</ins><span class="cx">         // e.g. {&quot;(WebKit,131456,\&quot;2012-10-16 14:53:00\&quot;)&quot;,&quot;(Chromium,162004,)&quot;}
</span><span class="cx">         $outer_array = json_decode('[' . trim($postgres_array, '{}') . ']');
</span><span class="cx">         $revisions = array();
</span><span class="lines">@@ -106,6 +121,7 @@
</span><span class="cx">             if (!$name_and_revision[0])
</span><span class="cx">                 continue;
</span><span class="cx">             $time = Database::to_js_time(trim($name_and_revision[2], '&quot;'));
</span><ins>+            $max_time = max($max_time, $time);
</ins><span class="cx">             $revisions[trim($name_and_revision[0], '&quot;')] = array(trim($name_and_revision[1], '&quot;'), $time);
</span><span class="cx">         }
</span><span class="cx">         return $revisions;
</span></span></pre>
</div>
</div>

</body>
</html>