From 97cabcecf27178834553e6d4e69783e5f88525d4 Mon Sep 17 00:00:00 2001 From: miqrogroove Date: Wed, 20 Jun 2018 06:06:20 -0400 Subject: [PATCH 1/5] Unify Worker Load Formulas --- src/Core/Worker.php | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index bc45be2d5..bafe37113 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -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')) { From 9cde4aa1096d9161773116b9358358698c524dc9 Mon Sep 17 00:00:00 2001 From: miqrogroove Date: Wed, 20 Jun 2018 06:22:53 -0400 Subject: [PATCH 2/5] Make Load Exponent Configurable --- src/Core/Worker.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index bafe37113..3df20c514 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -625,12 +625,7 @@ class Worker if ($load) { $maxsysload = intval(Config::get("system", "maxloadavg", 50)); - if (Config::get('system', 'worker_linear_load', false)) { - $exponent = 1; - } else { - $exponent = 3; - } - + $exponent = intval(Config::get('system', 'worker_load_exponent', 3)); $slope = pow(max(0, $maxsysload - $load) / $maxsysload, $exponent); $queues = intval(ceil($slope * $maxqueues)); From 3f69568365e2d229540e99f92b9fb31a01e04117 Mon Sep 17 00:00:00 2001 From: miqrogroove Date: Wed, 20 Jun 2018 06:29:52 -0400 Subject: [PATCH 3/5] Revise Description of New Worker Config --- doc/htconfig.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/htconfig.md b/doc/htconfig.md index 50fc4255f..95bda8bb9 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -94,7 +94,7 @@ Example: To set the automatic database cleanup process add this line to your .ht * **throttle_limit_month** - Maximum number of posts that a user can send per month with the API. * **wall-to-wall_share** (Boolean) - Displays forwarded posts like "wall-to-wall" posts. * **worker_cooldown** - Cooldown time after each worker function call. Default value is 0 seconds. -* **worker_linear_load** (Boolean) - Enables the linear calculation of maximum queues. +* **worker_load_exponent** (Integer) - Default 3, which allows only 25% of the maximum worker queues when server load reaches around 37% of maximum load. For a linear response where 25% of worker queues are allowed at 75% of maximum load, set this to 1. Queues will always reduce to zero when the maximum load is exceeded. * **xrd_timeout** - Timeout for fetching the XRD links. Default value is 20 seconds. ## experimental ## From 12d0f4bf3c17fb650036e301bb677ff736d5c178 Mon Sep 17 00:00:00 2001 From: miqrogroove Date: Wed, 20 Jun 2018 06:43:57 -0400 Subject: [PATCH 4/5] Add Comments to Worker Exponent Implementation --- src/Core/Worker.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 3df20c514..c965e0583 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -625,6 +625,11 @@ class Worker if ($load) { $maxsysload = intval(Config::get("system", "maxloadavg", 50)); + /* Default exponent 3 causes queues to rapidly decrease as load increases. + * If you have 20 max queues at idle, then you get only 5 queues at 37.1% of $maxsysload. + * For some environments, this rapid decrease is not needed. + * With exponent 1, you could have 20 max queues at idle and 13 at 37% of $maxsysload. + */ $exponent = intval(Config::get('system', 'worker_load_exponent', 3)); $slope = pow(max(0, $maxsysload - $load) / $maxsysload, $exponent); $queues = intval(ceil($slope * $maxqueues)); From f7e197c26e37bdd33ce58c3637e1840b8b99dee2 Mon Sep 17 00:00:00 2001 From: miqrogroove Date: Wed, 20 Jun 2018 06:52:53 -0400 Subject: [PATCH 5/5] Clarify 0 Value of Worker Exponent --- doc/htconfig.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/htconfig.md b/doc/htconfig.md index 95bda8bb9..296551244 100644 --- a/doc/htconfig.md +++ b/doc/htconfig.md @@ -94,7 +94,7 @@ Example: To set the automatic database cleanup process add this line to your .ht * **throttle_limit_month** - Maximum number of posts that a user can send per month with the API. * **wall-to-wall_share** (Boolean) - Displays forwarded posts like "wall-to-wall" posts. * **worker_cooldown** - Cooldown time after each worker function call. Default value is 0 seconds. -* **worker_load_exponent** (Integer) - Default 3, which allows only 25% of the maximum worker queues when server load reaches around 37% of maximum load. For a linear response where 25% of worker queues are allowed at 75% of maximum load, set this to 1. Queues will always reduce to zero when the maximum load is exceeded. +* **worker_load_exponent** (Integer) - Default 3, which allows only 25% of the maximum worker queues when server load reaches around 37% of maximum load. For a linear response where 25% of worker queues are allowed at 75% of maximum load, set this to 1. Setting 0 would allow maximum worker queues at all times, which is not recommended. * **xrd_timeout** - Timeout for fetching the XRD links. Default value is 20 seconds. ## experimental ##