php-http / curl-client

cURL client
http://httplug.io
MIT License
445 stars 28 forks source link

Issue 55 curl multirunner burn cpu #56

Open mekras opened 5 years ago

ricostone commented 4 years ago

Hi i'm running into this, any merge planned ? Any help needed ? We actually kickfixed like this ...

$status = curl_multi_exec($this->multiHandle, $active);
$info = curl_multi_info_read($this->multiHandle);
if (false !== $info) {
                ...
}else{
 // fixing issue https://github.com/php-http/curl-client/issues/55
 usleep(self::MULTI_RUNNER_USLEEP);
}
dbu commented 4 years ago

from https://github.com/elastic/elasticsearch-php/issues/990:

a solution proposed at https://bugs.php.net/bug.php?id=61141#1348321490 is

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) == -1) usleep(100);
    do { $mrc = curl_multi_exec($mh, $active); }
    while ($mrc == CURLM_CALL_MULTI_PERFORM);
}

(which we should format according to our code style, but functionality seems good to me. 100 micro seconds is 1 thousandst of a second, so should be an acceptable delay while lowering the cpu)