예제 #1
0
 public function __construct($container)
 {
     parent::__construct($container);
     //All this screens are using this custom filters
     $this->buildFilters(array('bench' => array('default' => array('terasort'), 'type' => 'selectOne', 'label' => 'Benchmark:')));
     $this->whereClause = $this->filters->getWhereClause();
     $this->clusterCosts = Utils::generateCostsFilters($this->container->getDBUtils());
 }
예제 #2
0
 public function bestConfigAction()
 {
     $db = $this->container->getDBUtils();
     $this->buildFilters(array('bench' => array('default' => array('terasort'), 'type' => 'selectOne', 'label' => 'Benchmark:'), 'ordertype' => array('default' => array('cost'), 'type' => 'selectOne', 'label' => 'Best config by:', 'generateChoices' => function () {
         return array('exe_time', 'cost');
     }, 'parseFunction' => function () {
         $ordertype = isset($_GET['ordertype']) ? $_GET['ordertype'] : 'cost';
         return array('currentChoice' => $ordertype, 'whereClause' => "");
     }, 'beautifier' => function ($value) {
         if ($value == 'exe_time') {
             return 'Execution time';
         } else {
             return 'Cost-effectiveness';
         }
     }, 'filterGroup' => 'basic')));
     $whereClause = $this->filters->getWhereClause();
     $model_html = '';
     $model_info = $db->get_rows("SELECT id_learner, model, algorithm, dataslice FROM aloja_ml.learners");
     foreach ($model_info as $row) {
         $model_html = $model_html . "<li><b>" . $row['id_learner'] . "</b> => " . $row['algorithm'] . " : " . $row['model'] . " : " . $row['dataslice'] . "</li>";
     }
     $clusterCosts = Utils::generateCostsFilters($db);
     $bestexec = '';
     $cluster = '';
     try {
         $order_type = Utils::get_GET_string('ordertype');
         if (!$order_type) {
             $order_type = 'exe_time';
         }
         $filterExecs = DBUtils::getFilterExecs();
         $params = $this->filters->getFiltersSelectedChoices(array('prediction_model', 'upred', 'uobsr'));
         $whereClauseML = str_replace("exe_time", "pred_time", $whereClause);
         $whereClauseML = str_replace("start_time", "creation_time", $whereClauseML);
         $queryObserved = "\n\t\t\t\t\tSELECT (e.exe_time/3600)*c.cost_hour as cost, e.id_exec,e.exec,e.bench,e.exe_time,e.net,e.disk,e.bench_type,e.maps,e.iosf,e.replication,e.iofilebuf,e.comp,e.blk_size,e.hadoop_version, c.*\n\t\t\t\t\tFROM aloja2.execs e JOIN aloja2.clusters c USING (id_cluster)\n\t\t\t\t\tLEFT JOIN aloja_ml.predictions AS p USING (id_exec)\n\t\t\t\t\tWHERE 1 {$filterExecs} {$whereClause}\n\t\t\t\t\tGROUP BY e.net,e.disk,e.bench_type,e.maps,e.iosf,e.replication,e.iofilebuf,e.comp,e.blk_size,e.hadoop_version\n\t\t\t\t\tORDER BY {$order_type} ASC\n\t\t\t\t";
         $queryPredictions = "SELECT (e.exe_time/3600)*c.cost_hour AS cost,e.id_exec,e.exec,CONCAT('Predicted ',e.bench) as bench,e.pred_time AS exe_time,e.net,e.disk,e.bench_type,e.maps,e.iosf,e.replication,e.iofilebuf,e.comp,e.blk_size,e.hadoop_version,c.*\n\t\t\t\t\tFROM aloja_ml.predictions AS e JOIN aloja2.clusters AS c USING (id_cluster)\n\t\t\t\t\tWHERE 1 {$filterExecs} " . str_replace("p.", "e.", $whereClauseML) . " AND id_learner = '" . $params['prediction_model'] . "'\n\t\t\t\t\tGROUP BY e.net,e.disk,e.bench_type,e.maps,e.iosf,e.replication,e.iofilebuf,e.comp,e.blk_size,e.hadoop_version";
         $query = $queryObserved;
         // get the result rows
         if ($params['uobsr'] == 1 && $params['upred'] == 1) {
             $query = "\n\t\t\t\t\t({$queryObserved})\n\t\t\t\t\tUNION\n\t\t\t\t\t({$queryPredictions})\n\t\t\t\t\tORDER BY {$order_type} ASC\n\t\t\t\t";
         } else {
             if ($params['uobsr'] == 0 && $params['upred'] == 1) {
                 $query = $queryPredictions;
             } else {
                 if ($params['uobsr'] == 0 && $params['upred'] == 0) {
                     $this->container->getTwig()->addGlobal('message', "Warning: No data selected (Predictions|Observations) from the ML Filters. Adding the Observed executions to the figure by default.\n");
                 }
             }
         }
         //		$this->getContainer ()->getLog ()->addInfo ( 'BestConfig query: ' . $query );
         $rows = $db->get_rows($query);
         if (!$rows) {
             throw new \Exception("No results for query!");
         }
         $minCost = -1;
         $minCostIdx = 0;
         if ($rows) {
             $bestexec = $rows[0];
             if ($order_type == 'cost') {
                 foreach ($rows as $key => &$exec) {
                     $cost = Utils::getExecutionCost($exec, $clusterCosts);
                     if ($cost < $minCost || $minCost == -1) {
                         $minCost = $cost;
                         $minCostIdx = $key;
                     }
                     $exec['cost'] = $cost;
                 }
                 $bestexec = $rows[$minCostIdx];
             } else {
                 $bestexec['cost'] = Utils::getExecutionCost($bestexec, $clusterCosts);
             }
             $cluster = $bestexec['name'];
             Utils::makeExecInfoBeauty($bestexec);
         }
     } catch (\Exception $e) {
         $this->container->getTwig()->addGlobal('message', $e->getMessage() . "\n");
     }
     $clusters = $db->get_rows("SELECT * FROM aloja2.clusters WHERE id_cluster IN (SELECT DISTINCT id_cluster FROM aloja2.execs e WHERE 1 {$filterExecs});");
     return $this->render('configEvaluationViews/bestconfig.html.twig', array('title' => 'Best Run Configuration', 'bestexec' => $bestexec, 'cluster' => $cluster, 'order_type' => $order_type, 'clusters' => $clusters, 'clusterCosts' => $clusterCosts, 'models' => $model_html));
 }