Title: [202000] trunk/Websites/perf.webkit.org
Revision
202000
Author
[email protected]
Date
2016-06-13 12:40:01 -0700 (Mon, 13 Jun 2016)

Log Message

/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.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (201999 => 202000)


--- 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)
@@ -1,3 +1,25 @@
+2016-06-13  Ryosuke Niwa  <[email protected]>
+
+        /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.
+
 2016-06-08  Ryosuke Niwa  <[email protected]>
 
         sync-buildbot.js should update the list of tests and platforms associated with a triggerable

Modified: trunk/Websites/perf.webkit.org/public/admin/tests.php (201999 => 202000)


--- 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)
@@ -3,51 +3,9 @@
 require_once('../include/admin-header.php');
 require_once('../include/test-name-resolver.php');
 
-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') {
+if ($action == 'update') {
     if (!update_field('tests', 'test', 'url'))
         notice('Invalid parameters');
-} 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));
-    }
 } else if ($action == 'add') {
     if (array_key_exists('test_id', $_POST) && array_key_exists('metric_name', $_POST)) {
         $id = intval($_POST['test_id']);
@@ -74,7 +32,11 @@
         foreach ($aggregators_table as $aggregator_row)
             $aggregators[$aggregator_row['aggregator_id']] = $aggregator_row['aggregator_name'];
     }
-    $build_triggerable_table = $db->fetch_table('build_triggerables', 'triggerable_name') or array();
+    $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;
+    }
 
     $test_name_resolver = new TestNameResolver($db);
     if ($test_name_resolver->tests()) {
@@ -96,7 +58,7 @@
 <table>
 <thead>
     <tr><td>Test ID</td><td>Full Name</td><td>Parent ID</td><td>URL</td><td>Triggerables</td>
-        <td>Metric ID</td><td>Metric Name</td><td>Aggregator</td><td>Dashboard</td>
+        <td>Metric ID</td><td>Metric Name</td><td>Aggregator</td>
 </thead>
 <tbody>
 <?php
@@ -110,45 +72,29 @@
             $row_count = count($test_metrics);
             $child_metrics = $test_name_resolver->child_metrics_for_test_id($test_id);
             $linked_test_name = htmlspecialchars($test['full_name']);
-            if ($child_metrics) {
-                $row_count++;
+            if ($child_metrics)
                 $linked_test_name = '<a href="" . htmlspecialchars($test['full_name']) . '">' . $linked_test_name . '</a>';
-            }
 
             $tbody_class = $odd ? 'odd' : 'even';
             $odd = !$odd;
 
             $test_url = htmlspecialchars($test['test_url']);
 
-            $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;
+            $triggerable_platform_list = '';
 
-                $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;
+            $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'];
             }
 
             echo <<<EOF
@@ -161,7 +107,7 @@
         <form method="POST"><input type="hidden" name="id" value="$test_id">
         <input type="hidden" name="action" value="update">
         <input type="url" name="url" value="$test_url" size="30"></form></td>
-        <td rowspan="$row_count">$triggerables</td>
+        <td rowspan="$row_count">$triggerable_platform_list</td>
 EOF;
 
             if ($test_metrics) {
@@ -186,62 +132,13 @@
         <td><a href=""
         <td>{$metric['metric_name']}</td>
         <td>$aggregator_name $aggregator_action</td>
-        <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>
     </tr>
 EOF;
                 }
-            }
+            } else
+                echo '<td colspan="3"></td>';
 
-            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>";
-            }
             echo <<<EOF
-        </select></label>
-        <button type="submit" name="action" value="add">Add</button></form></td>
-    </tr>
-EOF;
-            }
-            echo <<<EOF
     </tbody>
 EOF;
         }

Modified: trunk/Websites/perf.webkit.org/public/include/test-name-resolver.php (201999 => 202000)


--- 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)
@@ -8,7 +8,6 @@
         $this->test_id_to_child_metrics = array();
         $this->test_to_metrics = array();
         $this->tests_sorted_by_full_name = array();
-        $this->metric_to_configurations = array();
         $this->id_to_metric = array();
         $this->id_to_aggregator = array();
 
@@ -28,16 +27,6 @@
         $this->test_to_metrics = $this->map_metrics_to_tests($db->fetch_table('test_metrics'), $test_id_to_parent);
         $this->tests_sorted_by_full_name = $this->sort_tests_by_full_name($this->full_name_to_test);
 
-        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);
-            }
-        }
-
         if ($aggregator_table = $db->fetch_table('aggregators')) {
             foreach ($aggregator_table as $aggregator)
                 $this->id_to_aggregator[$aggregator['aggregator_id']] = $aggregator;
@@ -126,21 +115,9 @@
     }
 
     function configurations_for_metric_and_platform($metric_id, $platform_id) {
-        $metric_configurations = array_get($this->metric_to_configurations, $metric_id, array());
-        return array_get($metric_configurations, $platform_id);
+        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));
     }
-
-    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;
-    }
 }
 
 ?>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to