Merge pull request #2703 from annando/1608-worker-priority
Improvements for the fastlane and forgotten priority
This commit is contained in:
commit
f3ec28bd73
2
boot.php
2
boot.php
|
@ -2278,7 +2278,7 @@ function current_load() {
|
||||||
if (!is_array($load_arr))
|
if (!is_array($load_arr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return max($load_arr);
|
return max($load_arr[0], $load_arr[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1692,7 +1692,7 @@ class dfrn {
|
||||||
$changed = true;
|
$changed = true;
|
||||||
|
|
||||||
if ($entrytype == DFRN_REPLY_RC)
|
if ($entrytype == DFRN_REPLY_RC)
|
||||||
proc_run("php", "include/notifier.php","comment-import", $current["id"]);
|
proc_run(PRIORITY_HIGH, "include/notifier.php","comment-import", $current["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update last-child if it changes
|
// update last-child if it changes
|
||||||
|
@ -2252,7 +2252,7 @@ class dfrn {
|
||||||
|
|
||||||
if($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) {
|
if($posted_id AND $parent AND ($entrytype == DFRN_REPLY_RC)) {
|
||||||
logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG);
|
logger("Notifying followers about comment ".$posted_id, LOGGER_DEBUG);
|
||||||
proc_run("php", "include/notifier.php", "comment-import", $posted_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $posted_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2423,7 +2423,7 @@ class dfrn {
|
||||||
|
|
||||||
if($entrytype == DFRN_REPLY_RC) {
|
if($entrytype == DFRN_REPLY_RC) {
|
||||||
logger("Notifying followers about deletion of post ".$item["id"], LOGGER_DEBUG);
|
logger("Notifying followers about deletion of post ".$item["id"], LOGGER_DEBUG);
|
||||||
proc_run("php", "include/notifier.php","drop", $item["id"]);
|
proc_run(PRIORITY_HIGH, "include/notifier.php","drop", $item["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1184,7 +1184,7 @@ class diaspora {
|
||||||
);
|
);
|
||||||
|
|
||||||
// notify others
|
// notify others
|
||||||
proc_run("php", "include/notifier.php", "comment-import", $message_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
|
@ -1519,7 +1519,7 @@ class diaspora {
|
||||||
);
|
);
|
||||||
|
|
||||||
// notify others
|
// notify others
|
||||||
proc_run("php", "include/notifier.php", "comment-import", $message_id);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
|
@ -1799,7 +1799,7 @@ class diaspora {
|
||||||
|
|
||||||
$i = item_store($arr);
|
$i = item_store($arr);
|
||||||
if($i)
|
if($i)
|
||||||
proc_run("php", "include/notifier.php", "activity", $i);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2192,7 +2192,7 @@ class diaspora {
|
||||||
// Now check if the retraction needs to be relayed by us
|
// Now check if the retraction needs to be relayed by us
|
||||||
if($p[0]["origin"]) {
|
if($p[0]["origin"]) {
|
||||||
// notify others
|
// notify others
|
||||||
proc_run("php", "include/notifier.php", "drop", $r[0]["id"]);
|
proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $r[0]["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1712,7 +1712,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
|
||||||
} else
|
} else
|
||||||
$range = "AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY ";
|
$range = "AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY ";
|
||||||
|
|
||||||
$r = q("SELECT * FROM `item`
|
$r = q("SELECT `file`, `resource-id`, `starred`, `type`, `id` FROM `item`
|
||||||
WHERE `uid` = %d $range
|
WHERE `uid` = %d $range
|
||||||
AND `id` = `parent`
|
AND `id` = `parent`
|
||||||
$sql_extra
|
$sql_extra
|
||||||
|
|
|
@ -270,25 +270,24 @@ function poller_too_much_workers() {
|
||||||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||||
|
|
||||||
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($active >= $queues)) {
|
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
|
||||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` = '0000-00-00 00:00:00'",
|
$entries = $s[0]["total"];
|
||||||
intval(PRIORITY_HIGH));
|
|
||||||
$high_waiting = $s[0]["total"];
|
|
||||||
|
|
||||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` = %d AND `executed` != '0000-00-00 00:00:00'",
|
if (Config::get("system", "worker_fastlane", false) AND ($queues > 0) AND ($entries > 0) AND ($active >= $queues)) {
|
||||||
intval(PRIORITY_HIGH));
|
$s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority` LIMIT 1");
|
||||||
|
$top_priority = $s[0]["priority"];
|
||||||
|
|
||||||
|
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00'",
|
||||||
|
intval($top_priority));
|
||||||
$high_running = $s[0]["total"];
|
$high_running = $s[0]["total"];
|
||||||
|
|
||||||
/// @todo define maximum number of fastlanes
|
/// @todo define maximum number of fastlanes
|
||||||
if (($high_waiting > 0) AND ($high_running == 0)) {
|
if (($high_running == 0) AND ($top_priority >= PRIORITY_HIGH) AND ($top_priority < PRIORITY_LOW)) {
|
||||||
logger("There are ".$high_waiting." high priority jobs waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
|
logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
|
||||||
$queues = $active + 1;
|
$queues = $active + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00'");
|
|
||||||
$entries = $s[0]["total"];
|
|
||||||
|
|
||||||
logger("Current load: ".$load." - maximum: ".$maxsysload." - current queues: ".$active."/".$entries." - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
|
logger("Current load: ".$load." - maximum: ".$maxsysload." - current queues: ".$active."/".$entries." - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
|
||||||
|
|
||||||
// Are there fewer workers running as possible? Then fork a new one.
|
// Are there fewer workers running as possible? Then fork a new one.
|
||||||
|
|
Loading…
Reference in a new issue