]> git.mxchange.org Git - friendica.git/commitdiff
Fix worker statistics
authorMichael <heluecht@pirati.ca>
Mon, 11 Feb 2019 08:59:14 +0000 (08:59 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 11 Feb 2019 08:59:14 +0000 (08:59 +0000)
src/Core/Worker.php

index 206a300ee46a9bc94485ae46560f46babc041a49..3b575850c682c6f1097230f1b6581b57d5bda92c 100644 (file)
@@ -741,7 +741,15 @@ class Worker
 
                        $idle_workers = $active;
 
+                       if (empty($deferred) && empty($entries)) {
+                               $deferred = self::deferredEntries();
+                               $entries = max(self::totalEntries() - $deferred, 0);
+                       }
+
+                       $waiting_processes = max(0, $entries - $deferred);
+
                        if (Config::get('system', 'worker_debug')) {
+                               $waiting_processes = 0;
                                // Now adding all processes with workerqueue entries
                                $stamp = (float)microtime(true);
                                $jobs = DBA::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` AND `next_try` < ? GROUP BY `priority`", DateTimeFormat::utcNow());
@@ -754,6 +762,7 @@ class Worker
                                        self::$db_duration_stat += (microtime(true) - $stamp);
                                        if ($process = DBA::fetch($processes)) {
                                                $idle_workers -= $process["running"];
+                                               $waiting_processes += $entry["entries"];
                                                $listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
                                        }
                                        DBA::close($processes);
@@ -775,11 +784,6 @@ class Worker
 
                        $processlist .= ' ('.implode(', ', $listitem).')';
 
-                       if (empty($deferred) && empty($entries)) {
-                               $deferred = self::deferredEntries();
-                               $entries = max(self::totalEntries() - $deferred, 0);
-                       }
-
                        if (Config::get("system", "worker_fastlane", false) && ($queues > 0) && self::entriesExists() && ($active >= $queues)) {
                                $top_priority = self::highestPriority();
                                $high_running = self::processWithPriorityActive($top_priority);
@@ -790,7 +794,7 @@ class Worker
                                }
                        }
 
-                       Logger::log("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . ($entries - $deferred) . $processlist . " - maximum: " . $queues . "/" . $maxqueues, Logger::DEBUG);
+                       Logger::log("Load: " . $load ."/" . $maxsysload . " - processes: " . $deferred . "/" . $active . "/" . $waiting_processes . $processlist . " - maximum: " . $queues . "/" . $maxqueues, Logger::DEBUG);
 
                        // Are there fewer workers running as possible? Then fork a new one.
                        if (!Config::get("system", "worker_dont_fork", false) && ($queues > ($active + 1)) && ($entries > 1)) {