]> git.mxchange.org Git - friendica.git/commitdiff
Merge remote-tracking branch 'upstream/develop' into 1706-worker-even-faster
authorMichael <heluecht@pirati.ca>
Sun, 11 Jun 2017 07:49:34 +0000 (07:49 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 11 Jun 2017 07:49:34 +0000 (07:49 +0000)
Conflicts:
include/poller.php

1  2 
boot.php
doc/htconfig.md
include/notifier.php
include/poller.php

diff --cc boot.php
Simple merge
diff --cc doc/htconfig.md
Simple merge
Simple merge
index a1266d62c91bce67e755fd6bee9ddc00923eded6,cc8edce656969ba4e8743adac09d479724d2edee..8784931d3c6106652d3d542490769702f7a3e470
@@@ -487,41 -442,40 +487,41 @@@ function poller_too_much_workers($entri
                $slope = $maxworkers / pow($maxsysload, $exponent);
                $queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
  
 -              // Create a list of queue entries grouped by their priority
 -              $listitem = array();
 +              if (Config::get('system', 'worker_debug')) {
 +                      // Create a list of queue entries grouped by their priority
 +                      $listitem = array();
  
 -              // Adding all processes with no workerqueue entry
 -              $processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS (SELECT id FROM `workerqueue` WHERE `workerqueue`.`pid` = `process`.`pid`)");
 -              if ($process = dba::fetch($processes)) {
 -                      $listitem[0] = "0:".$process["running"];
 -              }
 -              dba::close($processes);
 -
 -              // Now adding all processes with workerqueue entries
 -              $entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
 -              while ($entry = dba::fetch($entries)) {
 -                      $processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE `priority` = ?", $entry["priority"]);
 +                      // Adding all processes with no workerqueue entry
 +                      $processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS (SELECT id FROM `workerqueue` WHERE `workerqueue`.`pid` = `process`.`pid`)");
                        if ($process = dba::fetch($processes)) {
 -                              $listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
 +                              $listitem[0] = "0:".$process["running"];
                        }
                        dba::close($processes);
 -              }
 -              dba::close($entries);
 -              $processlist = ' ('.implode(', ', $listitem).')';
  
 -              $s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
 -              $entries = $s[0]["total"];
 +                      // Now adding all processes with workerqueue entries
 +                      $entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
 +                      while ($entry = dba::fetch($entries)) {
 +                              $processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE `priority` = ?", $entry["priority"]);
 +                              if ($process = dba::fetch($processes)) {
 +                                      $listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
 +                              }
 +                              dba::close($processes);
 +                      }
 +                      dba::close($entries);
 +                      $processlist = ' ('.implode(', ', $listitem).')';
 +              }
  
-               if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
 +              if (is_null($entries)) {
 +                      $entries = poller_total_entries();
 +              }
 -                      $s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` <= '%s' ORDER BY `priority` LIMIT 1", dbesc(NULL_DATE));
 -                      $top_priority = $s[0]["priority"];
 -
 -                      $s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` > '%s' LIMIT 1",
 -                              intval($top_priority), dbesc(NULL_DATE));
 -                      $high_running = dbm::is_result($s);
 -
+               if (Config::get("system", "worker_fastlane", false) && ($queues > 0) && ($entries > 0) && ($active >= $queues)) {
-                       if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
 +                      if (is_null($top_priority)) {
 +                              $top_priority = poller_highest_priority();
 +                      }
 +                      if (is_null($high_running)) {
 +                              $high_running = poller_process_with_priority_active($top_priority);
 +                      }
+                       if (!$high_running && ($top_priority > PRIORITY_UNDEFINED) && ($top_priority < PRIORITY_NEGLIGIBLE)) {
                                logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
                                $queues = $active + 1;
                        }