]> git.mxchange.org Git - friendica.git/commitdiff
Unify Worker Load Formulas
authormiqrogroove <miqrogroove@gmail.com>
Wed, 20 Jun 2018 10:06:20 +0000 (06:06 -0400)
committerGitHub <noreply@github.com>
Wed, 20 Jun 2018 10:06:20 +0000 (06:06 -0400)
src/Core/Worker.php

index bc45be2d5b75da128966c7d98d56d0cb3dda2315..bafe3711301c66b0074562be934dac9a231d1db6 100644 (file)
@@ -626,34 +626,14 @@ class Worker
                        $maxsysload = intval(Config::get("system", "maxloadavg", 50));
 
                        if (Config::get('system', 'worker_linear_load', false)) {
-                               /* The linear load calculation works fine if there is a low
-                                * number of maximum queues and a high load base level.
-                                * This can be present at shared hosters.
-                               */
-                               $tinyload = 1;
-
-                               if ($load > $maxsysload) {
-                                       $queues = 0;
-                               } elseif ($load > $tinyload) {
-                                       //Provide $queues number between 1 (below max load) and $maxqueues - 1 (above tiny load).
-                                       $range = $maxsysload - $tinyload;
-                                       $slope = 1.00 - (($load - $tinyload) / $range);
-                                       $target = $slope * ($maxqueues - 1);
-                                       $queues = intval(ceil($target));
-                               }
+                               $exponent = 1;
                        } else {
-                               /* The exponentional load calculation respects the load behaviour
-                                * of Linux systems with regular hardware that normally idles
-                                * with load values near 0.
-                               */
-                               $maxworkers = $queues;
-
-                               // Some magical mathemathics to reduce the workers
                                $exponent = 3;
-                               $slope = $maxworkers / pow($maxsysload, $exponent);
-                               $queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
                        }
 
+                       $slope = pow(max(0, $maxsysload - $load) / $maxsysload, $exponent);
+                       $queues = intval(ceil($slope * $maxqueues));
+
                        $processlist = '';
 
                        if (Config::get('system', 'worker_debug')) {