Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 55 curl multirunner burn cpu #56

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

mekras
Copy link
Collaborator

@mekras mekras commented Apr 10, 2019

No description provided.

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for looking into this. some comments and questions:

$info = curl_multi_info_read($this->multiHandle);
if (false !== $info) {
if ($info !== false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't revert yoda style comparisons.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it has nothing to do with the change at hand.

i would have expected the code style checker to complain, but seems we don't have a rule for this activated.

}

do {
$status = curl_multi_exec($this->multiHandle, $active);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this now again busy waiting? should we repeat the curl_multi_select in each loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not pretty sure. Most examples I've found are like this https://bugs.php.net/bug.php?id=61141#1348321490

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its again the same as guzzle does, which is most likely what the symfony http client is using, so i'd hope its the right thing.

src/MultiRunner.php Show resolved Hide resolved
@ricostone
Copy link

ricostone commented Dec 10, 2019

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
Copy link
Contributor

dbu commented Jan 22, 2020

from elastic/elasticsearch-php#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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants