]> git.mxchange.org Git - friendica.git/commitdiff
Fetching new queue tasks in a bulk to increase speed
authorMichael <heluecht@pirati.ca>
Tue, 13 Jun 2017 13:51:25 +0000 (13:51 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 13 Jun 2017 13:51:25 +0000 (13:51 +0000)
include/poller.php

index 0c92d00875f865248882e5d274a179e23db1645c..4801ea8fdf09aaa20d1998b63b0d4162ccf18b0e 100644 (file)
@@ -96,26 +96,26 @@ function poller_run($argv, $argc){
                                logger('Process execution failed, quitting.', LOGGER_DEBUG);
                                return;
                        }
+               }
 
-                       // To avoid the quitting of multiple pollers only one poller at a time will execute the check
-                       if (Lock::set('poller_worker', 0)) {
-                               // Count active workers and compare them with a maximum value that depends on the load
-                               if (poller_too_much_workers()) {
-                                       logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
-                                       return;
-                               }
+               // To avoid the quitting of multiple pollers only one poller at a time will execute the check
+               if (Lock::set('poller_worker', 0)) {
+                       // Count active workers and compare them with a maximum value that depends on the load
+                       if (poller_too_much_workers()) {
+                               logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
+                               return;
+                       }
 
-                               // Check free memory
-                               if ($a->min_memory_reached()) {
-                                       logger('Memory limit reached, quitting.', LOGGER_DEBUG);
-                                       return;
-                               }
-                               Lock::remove('poller_worker');
+                       // Check free memory
+                       if ($a->min_memory_reached()) {
+                               logger('Memory limit reached, quitting.', LOGGER_DEBUG);
+                               return;
                        }
+                       Lock::remove('poller_worker');
                }
 
-               // Quit the poller once every hour
-               if (time() > ($starttime + 3600)) {
+               // Quit the poller once every 5 minutes
+               if (time() > ($starttime + 300)) {
                        logger('Process lifetime reached, quitting.', LOGGER_DEBUG);
                        return;
                }
@@ -610,7 +610,7 @@ function find_worker_processes() {
                // Are there waiting processes with a higher priority than the currently highest?
                $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ?
                                        WHERE `executed` <= ? AND `priority` < ?
-                                       ORDER BY `priority`, `created` LIMIT 1",
+                                       ORDER BY `priority`, `created` LIMIT 5",
                                datetime_convert(), getmypid(), NULL_DATE, $highest_priority);
                if (dbm::is_result($result)) {
                        $found = (dba::num_rows($result) > 0);
@@ -632,7 +632,7 @@ function find_worker_processes() {
 
        // If there is no result (or we shouldn't pass lower processes) we check without priority limit
        if (!$found) {
-               $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 1",
+               $result = dba::p("UPDATE `workerqueue` SET `executed` = ?, `pid` = ? WHERE `executed` <= ? ORDER BY `priority`, `created` LIMIT 5",
                                datetime_convert(), getmypid(), NULL_DATE);
                if (dbm::is_result($result)) {
                        $found = (dba::num_rows($result) > 0);