<!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>[202000] 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/202000">202000</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-13 12:40:01 -0700 (Mon, 13 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>/admin/tests is very slow
https://bugs.webkit.org/show_bug.cgi?id=158682
Reviewed by Chris Dumez.
The slowness came from TestNameResolver::__construct, which was fetching the entire table of test_configurations,
which at this point contains more than 32,000 rows. Don't fetch the entire table in the constructor. Instead,
fetch a subset of rows as needed in configurations_for_metric_and_platform. Even though this results in many SQL
queries being issued, that's a lot more efficient in practice because we only fetch a few dozen rows in practice.
Also removed a whole bunch of features from /admin/tests to simplify the page. In particular, the ability to update
the list of triggerables has been removed now that sync-buildbot.js automatically updates that for us. This removed
the last use of test_exists_on_platform, which was also dependent on fetching test_configurations upfront.
* public/admin/tests.php:
* public/include/test-name-resolver.php:
(TestNameResolver::__construct): Don't fetch the entire table of test_configurations.
(TestNameResolver::configurations_for_metric_and_platform): Just issue a SQL query for the specified platform and metric.
(TestNameResolver::test_exists_on_platform): Removed.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicadmintestsphp">trunk/Websites/perf.webkit.org/public/admin/tests.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicincludetestnameresolverphp">trunk/Websites/perf.webkit.org/public/include/test-name-resolver.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 (201999 => 202000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2016-06-13 19:39:01 UTC (rev 201999)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2016-06-13 19:40:01 UTC (rev 202000)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-06-13 Ryosuke Niwa <rniwa@webkit.org>
+
+ /admin/tests is very slow
+ https://bugs.webkit.org/show_bug.cgi?id=158682
+
+ Reviewed by Chris Dumez.
+
+ The slowness came from TestNameResolver::__construct, which was fetching the entire table of test_configurations,
+ which at this point contains more than 32,000 rows. Don't fetch the entire table in the constructor. Instead,
+ fetch a subset of rows as needed in configurations_for_metric_and_platform. Even though this results in many SQL
+ queries being issued, that's a lot more efficient in practice because we only fetch a few dozen rows in practice.
+
+ Also removed a whole bunch of features from /admin/tests to simplify the page. In particular, the ability to update
+ the list of triggerables has been removed now that sync-buildbot.js automatically updates that for us. This removed
+ the last use of test_exists_on_platform, which was also dependent on fetching test_configurations upfront.
+
+ * public/admin/tests.php:
+ * public/include/test-name-resolver.php:
+ (TestNameResolver::__construct): Don't fetch the entire table of test_configurations.
+ (TestNameResolver::configurations_for_metric_and_platform): Just issue a SQL query for the specified platform and metric.
+ (TestNameResolver::test_exists_on_platform): Removed.
+
</ins><span class="cx"> 2016-06-08 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> sync-buildbot.js should update the list of tests and platforms associated with a triggerable
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicadmintestsphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/admin/tests.php (201999 => 202000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/admin/tests.php        2016-06-13 19:39:01 UTC (rev 201999)
+++ trunk/Websites/perf.webkit.org/public/admin/tests.php        2016-06-13 19:40:01 UTC (rev 202000)
</span><span class="lines">@@ -3,51 +3,9 @@
</span><span class="cx"> require_once('../include/admin-header.php');
</span><span class="cx"> require_once('../include/test-name-resolver.php');
</span><span class="cx">
</span><del>-if ($action == 'dashboard') {
- if (array_key_exists('metric_id', $_POST)) {
- $metric_id = intval($_POST['metric_id']);
- $config_ids = array();
- $succeeded = TRUE;
- if (!$db->query_and_get_affected_rows("UPDATE test_configurations SET config_is_in_dashboard = false WHERE config_metric = $1", array($metric_id))) {
- $succeeded = FALSE;
- notice("Failed to remove some configurations from the dashboard.");
- }
-
- else if (array_key_exists('metric_platforms', $_POST)) {
- foreach ($_POST['metric_platforms'] as $platform_id) {
- if (!$db->query_and_get_affected_rows("UPDATE test_configurations SET config_is_in_dashboard = true
- WHERE config_metric = $1 AND config_platform = $2", array($metric_id, $platform_id))) {
- $succeeded = FALSE;
- notice("Failed to add configurations for metric $metric_id and platform $platform_id to the dashboard.");
- }
- }
- }
-
- if ($succeeded) {
- notice("Updated the dashboard.");
- regenerate_manifest();
- }
- } else
- notice('Invalid parameters');
-} else if ($action == 'update') {
</del><ins>+if ($action == 'update') {
</ins><span class="cx"> if (!update_field('tests', 'test', 'url'))
</span><span class="cx"> notice('Invalid parameters');
</span><del>-} else if ($action == 'update-triggerable') {
- $test_id = intval($_POST['test']);
- $platform_id = intval($_POST['platform']);
-
- $triggerable_id = array_get($_POST, 'triggerable');
- if ($triggerable_id) {
- $triggerable_id = intval($triggerable_id);
- $association = array('test' => $test_id, 'platform' => $platform_id, 'triggerable' => $triggerable_id);
- if (!$db->insert_row('triggerable_configurations', 'trigconfig', $association, NULL)) {
- $suceeded = FALSE;
- notice("Failed to associate triggerable $triggerable_id with test $test_id on platform $platform_id.");
- }
- } else {
- $db->query_and_get_affected_rows('DELETE FROM triggerable_configurations WHERE trigconfig_test = $1 AND trigconfig_platform = $2',
- array($test_id, $platform_id));
- }
</del><span class="cx"> } else if ($action == 'add') {
</span><span class="cx"> if (array_key_exists('test_id', $_POST) && array_key_exists('metric_name', $_POST)) {
</span><span class="cx"> $id = intval($_POST['test_id']);
</span><span class="lines">@@ -74,7 +32,11 @@
</span><span class="cx"> foreach ($aggregators_table as $aggregator_row)
</span><span class="cx"> $aggregators[$aggregator_row['aggregator_id']] = $aggregator_row['aggregator_name'];
</span><span class="cx"> }
</span><del>- $build_triggerable_table = $db->fetch_table('build_triggerables', 'triggerable_name') or array();
</del><ins>+ $triggerables = array();
+ if ($triggerable_table = $db->fetch_table('build_triggerables', 'triggerable_name')) {
+ foreach ($triggerable_table as $triggerable_row)
+ $triggerables[$triggerable_row['triggerable_id']] = $triggerable_row;
+ }
</ins><span class="cx">
</span><span class="cx"> $test_name_resolver = new TestNameResolver($db);
</span><span class="cx"> if ($test_name_resolver->tests()) {
</span><span class="lines">@@ -96,7 +58,7 @@
</span><span class="cx"> <table>
</span><span class="cx"> <thead>
</span><span class="cx"> <tr><td>Test ID</td><td>Full Name</td><td>Parent ID</td><td>URL</td><td>Triggerables</td>
</span><del>- <td>Metric ID</td><td>Metric Name</td><td>Aggregator</td><td>Dashboard</td>
</del><ins>+ <td>Metric ID</td><td>Metric Name</td><td>Aggregator</td>
</ins><span class="cx"> </thead>
</span><span class="cx"> <tbody>
</span><span class="cx"> <?php
</span><span class="lines">@@ -110,45 +72,29 @@
</span><span class="cx"> $row_count = count($test_metrics);
</span><span class="cx"> $child_metrics = $test_name_resolver->child_metrics_for_test_id($test_id);
</span><span class="cx"> $linked_test_name = htmlspecialchars($test['full_name']);
</span><del>- if ($child_metrics) {
- $row_count++;
</del><ins>+ if ($child_metrics)
</ins><span class="cx"> $linked_test_name = '<a href="/admin/tests/' . htmlspecialchars($test['full_name']) . '">' . $linked_test_name . '</a>';
</span><del>- }
</del><span class="cx">
</span><span class="cx"> $tbody_class = $odd ? 'odd' : 'even';
</span><span class="cx"> $odd = !$odd;
</span><span class="cx">
</span><span class="cx"> $test_url = htmlspecialchars($test['test_url']);
</span><span class="cx">
</span><del>- $triggerable_platforms = $db->query_and_fetch_all('SELECT * FROM platforms
- LEFT OUTER JOIN triggerable_configurations ON trigconfig_platform = platform_id AND trigconfig_test = $1 ORDER BY platform_name', array($test_id));
- $triggerables = '';
- foreach ($triggerable_platforms as $platform_row) {
- if (!$test_name_resolver->test_exists_on_platform($test_id, $platform_row['platform_id']))
- continue;
</del><ins>+ $triggerable_platform_list = '';
</ins><span class="cx">
</span><del>- $triggerables .= <<< END
-<form method="POST">
- <input type="hidden" name="test" value="$test_id">
- <input type="hidden" name="platform" value="{$platform_row['platform_id']}">
- <input type="hidden" name="action" value="update-triggerable">
- <label>
- {$platform_row['platform_name']}
- <select name="triggerable" onchange="this.form.submit();">
- <option value="">None</option>
-END;
- $selected_triggerable = array_get($platform_row, 'trigconfig_triggerable');
- foreach ($build_triggerable_table as $triggerable_row) {
- $triggerable_id = $triggerable_row['triggerable_id'];
- $selected = $triggerable_id == $selected_triggerable ? ' selected' : '';
- $triggerables .= "<option value=\"$triggerable_id\"$selected>{$triggerable_row['triggerable_name']}</option>";
- }
- $triggerables .= <<< END
- </select>
- </label>
-</form>
-<br>
-END;
</del><ins>+ $triggerable_platforms = $db->query_and_fetch_all('SELECT * FROM platforms JOIN triggerable_configurations
+ ON trigconfig_platform = platform_id AND trigconfig_test = $1 ORDER BY trigconfig_triggerable', array($test_id));
+ $previous_triggerable = null;
+ foreach ($triggerable_platforms as $row) {
+ if ($previous_triggerable != $row['trigconfig_triggerable']) {
+ $previous_triggerable = $row['trigconfig_triggerable'];
+ if ($triggerable_platform_list)
+ $triggerable_platform_list .= '<br>';
+ $name = $triggerables[$previous_triggerable]['triggerable_name'];
+ $triggerable_platform_list .= "<strong>$name:</strong> ";
+ } else
+ $triggerable_platform_list .= ', ';
+ $triggerable_platform_list .= $row['platform_name'];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> echo <<<EOF
</span><span class="lines">@@ -161,7 +107,7 @@
</span><span class="cx"> <form method="POST"><input type="hidden" name="id" value="$test_id">
</span><span class="cx"> <input type="hidden" name="action" value="update">
</span><span class="cx"> <input type="url" name="url" value="$test_url" size="30"></form></td>
</span><del>- <td rowspan="$row_count">$triggerables</td>
</del><ins>+ <td rowspan="$row_count">$triggerable_platform_list</td>
</ins><span class="cx"> EOF;
</span><span class="cx">
</span><span class="cx"> if ($test_metrics) {
</span><span class="lines">@@ -186,62 +132,13 @@
</span><span class="cx"> <td><a href="/admin/test-configurations?metric=$metric_id">$metric_id</a></td>
</span><span class="cx"> <td>{$metric['metric_name']}</td>
</span><span class="cx"> <td>$aggregator_name $aggregator_action</td>
</span><del>- <td><form method="POST"><input type="hidden" name="metric_id" value="$metric_id">
-EOF;
-
- foreach ($platform_names as $platform_name) {
- $platform_name = htmlspecialchars($platform_name);
- $platform = $name_to_platform[$platform_name];
- $configurations = $test_name_resolver->configurations_for_metric_and_platform($metric_id, $platform['platform_id']);
- if (!$configurations)
- continue;
- echo "<label><input type=\"checkbox\" name=\"metric_platforms[]\" value=\"{$platform['platform_id']}\"";
- if (Database::is_true($configurations[0]['config_is_in_dashboard']))
- echo ' checked';
- else if (Database::is_true($platform['platform_hidden']))
- echo 'disabled';
- echo ">$platform_name</label>";
- }
-
- echo <<<EOF
- <button type="submit" name="action" value="dashboard">Save</button></form>
- </td>
</del><span class="cx"> </tr>
</span><span class="cx"> EOF;
</span><span class="cx"> }
</span><del>- }
</del><ins>+ } else
+ echo '<td colspan="3"></td>';
</ins><span class="cx">
</span><del>- if ($child_metrics) {
- echo <<<EOF
- <td colspan="5"><form method="POST">
- <input type="hidden" name="test_id" value="$test_id">
- <label>Name<select name="metric_name">
-EOF;
-
- foreach ($child_metrics as $metric) {
- $metric_name = htmlspecialchars($metric['metric_name']);
- echo "
- <option>$metric_name</option>";
- }
-
- echo <<<EOF
- </select></label>
- <label>Aggregator
- <select name="metric_aggregator">
- <option value="">-</option>
-EOF;
- foreach ($aggregators as $id => $name) {
- $name = htmlspecialchars($name);
- echo "
- <option value=\"$id\">$name</option>";
- }
</del><span class="cx"> echo <<<EOF
</span><del>- </select></label>
- <button type="submit" name="action" value="add">Add</button></form></td>
- </tr>
-EOF;
- }
- echo <<<EOF
</del><span class="cx"> </tbody>
</span><span class="cx"> EOF;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicincludetestnameresolverphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/include/test-name-resolver.php (201999 => 202000)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/include/test-name-resolver.php        2016-06-13 19:39:01 UTC (rev 201999)
+++ trunk/Websites/perf.webkit.org/public/include/test-name-resolver.php        2016-06-13 19:40:01 UTC (rev 202000)
</span><span class="lines">@@ -8,7 +8,6 @@
</span><span class="cx"> $this->test_id_to_child_metrics = array();
</span><span class="cx"> $this->test_to_metrics = array();
</span><span class="cx"> $this->tests_sorted_by_full_name = array();
</span><del>- $this->metric_to_configurations = array();
</del><span class="cx"> $this->id_to_metric = array();
</span><span class="cx"> $this->id_to_aggregator = array();
</span><span class="cx">
</span><span class="lines">@@ -28,16 +27,6 @@
</span><span class="cx"> $this->test_to_metrics = $this->map_metrics_to_tests($db->fetch_table('test_metrics'), $test_id_to_parent);
</span><span class="cx"> $this->tests_sorted_by_full_name = $this->sort_tests_by_full_name($this->full_name_to_test);
</span><span class="cx">
</span><del>- if ($configurations = $db->fetch_table('test_configurations')) {
- foreach ($configurations as $config) {
- $metric_id = $config['config_metric'];
- $platform_id = $config['config_platform'];
- array_set_default($this->metric_to_configurations, $metric_id, array());
- array_set_default($this->metric_to_configurations[$metric_id], $platform_id, array());
- array_push($this->metric_to_configurations[$metric_id][$platform_id], $config);
- }
- }
-
</del><span class="cx"> if ($aggregator_table = $db->fetch_table('aggregators')) {
</span><span class="cx"> foreach ($aggregator_table as $aggregator)
</span><span class="cx"> $this->id_to_aggregator[$aggregator['aggregator_id']] = $aggregator;
</span><span class="lines">@@ -126,21 +115,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function configurations_for_metric_and_platform($metric_id, $platform_id) {
</span><del>- $metric_configurations = array_get($this->metric_to_configurations, $metric_id, array());
- return array_get($metric_configurations, $platform_id);
</del><ins>+ return $this->db->query_and_fetch_all('SELECT * FROM test_configurations WHERE config_metric = $1 AND config_platform = $2
+ ORDER BY config_id', array($metric_id, $platform_id));
</ins><span class="cx"> }
</span><del>-
- function test_exists_on_platform($test_id, $platform_id) {
- foreach ($this->metrics_for_test_id($test_id) as $metric) {
- if ($this->configurations_for_metric_and_platform($metric['metric_id'], $platform_id))
- return TRUE;
- }
- foreach ($this->child_metrics_for_test_id($test_id) as $metric) {
- if ($this->configurations_for_metric_and_platform($metric['metric_id'], $platform_id))
- return TRUE;
- }
- return FALSE;
- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>