amitmmc1 / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

cli longrun example high cpu #51

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.put in login credentials in cli-longrun example php 
2.run php cli_longrun_example.php 
3.check top

What is the expected output? What do you see instead?

output works perfectly but cpu is at 100%

What version of the product are you using? On what operating system?
xmpphp .1 rc1 rev 70
Debian 4.0
php  5.2.0-8
ejabberd 2.0.1
only extension I am loading in php is imagick.so

Original issue reported on code.google.com by bradwood...@gmail.com on 1 Apr 2009 at 8:28

GoogleCodeExporter commented 8 years ago
I'm seeing the same CPU usage issue.

XMPPHP 0.1 RC1 (rev 70)
CentOS 5.2
PHP 5.2.6
Openfire 3.6.3

Original comment by aiden...@yahoo.com on 2 Apr 2009 at 4:18

GoogleCodeExporter commented 8 years ago
I'm nearly identical as aiden... seeing the same issue with RC1 and openFire 
3.6.3

Original comment by mrk...@gmail.com on 3 Apr 2009 at 2:50

GoogleCodeExporter commented 8 years ago
It's fixed in SVN.  I suppose it's time for a new release.

Original comment by nathanfr...@gmail.com on 3 Apr 2009 at 8:22

GoogleCodeExporter commented 8 years ago
Hi,

I saw one "5" (microseconds?) wait, if I'm not wrong... IMO it's not enough 
(70%-80% CPU load here). 
Something like (500) seems to reduce it to 10%-12% here.(better but not sure if 
one idle daemon should use 
more that 1% at all).

In any case, couldn't that be configured in some place instead making 
processUntil() to use that configuration?

Just IMHO, ciao :-)

Original comment by stro...@stronk7.com on 24 Apr 2009 at 11:38

GoogleCodeExporter commented 8 years ago
Great news Fritzy.  Any ETA on the new RC?

Original comment by mrk...@gmail.com on 4 May 2009 at 8:53

GoogleCodeExporter commented 8 years ago
I tried grabbing the latest from svn and it still had the same CPU usage 
problem.  I
found that by adding a usleep to __process() for a mini timeout, I was able to 
go
from 99% CPU to 0.2% CPU which is a heck of a lot better.

private function __process($maximum=0) {

    $remaining = $maximum;

        do {
                        usleep(100000);

Original comment by paulside...@gmail.com on 5 May 2009 at 12:53

GoogleCodeExporter commented 8 years ago
Nice PaulSK.  Fritz, any official keeper comments?

Original comment by mrk...@gmail.com on 8 May 2009 at 8:57

GoogleCodeExporter commented 8 years ago
I have found solution for me.

file XMLStream.php
new lines
    } else if ($maximum == 0) {
        $secs = 0;
        $usecs = 200000; // sleep for 200 miliseconds, if no data
    } else {

and in the my code
    $xmpp->processUntil(array('message'), 0.1);

Original comment by alexxz2...@gmail.com on 17 Aug 2009 at 5:08

GoogleCodeExporter commented 8 years ago
Switching from 0.1rc2-r77 to svn dropped from 44% to 28% to 42%.  But my bot 
still
uses more processor than mythbackend while active(~10%).  

The php.net/stream_select page suggests 200000 microseconds to lower cpu usage. 
Patch attached for what I did.  I'm no longer at the top of top.  

Patch attached.  It's not perfect just my hack.  

Original comment by toddejoh...@gmail.com on 24 Sep 2009 at 11:00

Attachments:

GoogleCodeExporter commented 8 years ago
This issue is fixed in http://github.com/cweiske/xmpphp

Original comment by cwei...@cweiske.de on 25 Feb 2010 at 6:27

GoogleCodeExporter commented 8 years ago
issue #68 duplicates this one

Original comment by cwei...@cweiske.de on 25 Feb 2010 at 6:28