High CPU usage, and a few php warnings

Report bugs/flaws here

High CPU usage, and a few php warnings

Postby Sander on 30 Jan 2008, 19:50

Hi there.
A long time I've waited for phpbnc, and when I almost forgot about it, there was 0.16-beta :)
I'm currently running miau, and for each connection I need an own process with it's own config, not very flexible.

So, I hope to get phpbnc running perfectly.

My first concern currently is the abnormal high cpu usage.
My server I'm using is not a high end server, it's an Epia Via C3, 1300 MHz, with 1 GB memory.
Which is more then enough for my functions.
I'm running another PHP process, an IRC bot, and it hardly takes cpu load.

sander@Homer:~$ ps aux | grep php
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sander 28454 0.8 0.7 20508 7312 ? S Jan23 285:48 /usr/bin/php5 -q ./start.php
sander 31403 75.3 1.1 23888 10900 pts/4 R+ 18:39 18:29 php main.php
sander 31429 1.0 0.0 2972 764 pts/0 R+ 19:03 0:00 grep php


As you can see, main.php, aka phpbnc, takes up to 75% cpu usage.
I think the cause is the ioncube loader, but I don't know exactly how I can test this.

As a reference, 4 miau bnc processes on the same machine, with ~30 (5 high activity) channels open.
sander@Homer:~$ ps aux | grep miau
sander 31367 0.0 0.0 2096 968 pts/4 S 18:27 0:00 miau -d /home/sander/Programs/.miau/configs/*/
sander 31369 0.0 0.0 2100 964 pts/4 S 18:27 0:01 miau -d /home/sander/Programs/.miau/configs/*/
sander 31371 0.0 0.0 2088 956 pts/4 S 18:27 0:00 miau -d /home/sander/Programs/.miau/configs/*/
sander 31373 0.0 0.0 2096 960 pts/4 S 18:27 0:00 miau -d /home/sander/Programs/.miau/configs/*/
sander 31432 0.0 0.0 2976 752 pts/0 R+ 19:06 0:00 grep miau


Almost no cpu/mem usage.

Below is my normal load, almost idle
sander@Homer:~/Programs/phpbnc$ uptime
19:38:14 up 95 days, 5:46, 4 users, load average: 0.00, 0.00, 0.00

This is my load when running phpbnc:
sander@Homer:~/Programs/phpbnc$ uptime
19:23:41 up 95 days, 5:32, 4 users, load average: 1.04, 1.09, 1.04

When I disconnect my irc client, and let phpbnc log everything (/pb set channellog on), the load is even higher:
sander@Homer:~/Programs/phpbnc$ uptime
19:25:18 up 95 days, 5:33, 4 users, load average: 1.45, 1.27, 1.11

So I really hope this can be solved :)
There is no way I'm gonna run phpbnc with such high cpu loads.

And now, a few warnings I got while running phpbnc.
In the config.php:
define("identdip", "0.0.0.0"); //recommended to have 0.0.0.0

So, when I leave this value to 0.0.0.0, and start phpbnc:
sander@Homer:~/Programs/phpbnc$ php main.php
Connecting to MySQL...
Connected to MySQL.
Starting listening sockets...
0
0

Warning: stream_socket_server(): unable to connect to tcp://0.0.0.0:113 (Permission denied) in /home/sander/Programs/phpbnc/main.php on line 0
0 Permission denied[/b[
Sockets up and runnning.
Loading usersettings into memory...
Loaded usersettings into memory.
Loading blowfish keys into memory...
Loaded blowfish keys into memory.
Im good to go, phpBNC v.0.16-beta, http://www.phpBNC.se/
Starting in..5..4..3..2..1..

Warning: stream_select(): supplied argument is not a valid stream resource in /home/sander/Programs/phpbnc/main.php on line 0

Warning: stream_select(): supplied argument is not a valid stream resource in /home/sander/Programs/phpbnc/main.php on line 0

Warning: stream_select(): supplied argument is not a valid stream resource in /home/sander/Programs/phpbnc/main.php on line 0

Warning: fclose(): supplied argument is not a valid stream resource in /home/sander/Programs/phpbnc/main.php on line 0
identd request got disconnected


Even tried to change the identdip to 10.0.0.1, my server IP, but I got the same warning.

And I've still some general questions left :P
1: Channellogs: Is is possible to control how many lines are "readed" when you reconnect to the BNC?
Currently all the logs are "readed", which isn't very useful on a channel with ~5 lines per second.

2: Channellogs: Logging in MySQL is fun, but I would be glad if it is possible to log in plain text files, somewhat simular to mIRC logging.
At miau I'm using logfiles for all channels (After configuring them in the config...) even when I'm connected to the BNC. I love logs.

3: Channellogs: It would be nice if you could log always, even when you are on the channel.
Again a personal request :P But I'd like to have logs of everything :D

Oh, and before I forgot, keep up the good work!
There aren't many good BNC's for IRC, so there isn't much to choose, and I really hope that I can take the step to phpbnc some day :)
Sander
 
Posts: 2
Joined: 30 Jan 2008, 19:03

Re: High CPU usage, and a few php warnings

Postby blodan on 01 Feb 2008, 16:01

Hi,

Thanks for the input, im going to try to answer your questions one by one

First off, about your cpu problem, i dont really know why your cpu load is so high, mine is around 0.5-1% almost all the time, and im currently having 12 users testing it out. (see links)
http://www.phpbnc.com/imgs/sysusage.png
http://www.phpbnc.com/imgs/bncstats.png

However i know one issue that can cause this, that would be that the php function usleep() doesnt work in your enviorment for some reason, what you can try is makeing a php file containing this code:
  1. <?
  2. $counter = 0;
  3. while(true) {
  4.     usleep(2);
  5.     echo $counter." Hi! Im alive";
  6.     $counter++;
  7. }
  8. ?>

then do php thefile.php, if that file has a high cpu usage then thats whats the problem, because it shouldnt. However if its still high, try encreasing the usleep() value until your load is around 1%, try going in groups of thousands like 1000, 2000 and so on or you might just try 99999999999999999999 just to see if it helps at all :)

------------------------

About your warnings
As you can see in your paste it states
Warning: stream_socket_server(): unable to connect to tcp://0.0.0.0:113 (Permission denied) in /home/sander/Programs/phpbnc/main.php on line 0
0 Permission denied[/b

This means that the account your starting the bnc with doesnt have access to the tcp port 113 (which is the ident port), to get rid of this problem you simply have to give your own account access to port 113 or run it as root or deactive the built in ident server. And the warnings after the permission denied is a further chain of the same problem, it tries to read the ident socket but as you dont have permission to create a socket there isnt anyone hence the stream_select warnings

-----

About your other requests, there will be a plugin option available later on where you can include your own php code, but as this only is a beta and i got some work to do until i can release it as final, this will have to wait (a loooong time)

Hope this helped you out

Daniel
User avatar
blodan
Site Admin
 
Posts: 27
Joined: 17 Nov 2007, 00:16

Re: High CPU usage, and a few php warnings

Postby Sander on 02 Feb 2008, 12:56

Thank you for your reply.

I've ran the php script, and with the default usleep(2); value, I've got a 28% cpu load on the php process.
Changing it to 100 and the CPU usage is about 15%.

Ah well, if nobody else has this kind of high CPU usages it has to be something in my configuration, or maybe the hardware itself.
I will look forward to new releases and see if it somehow improves :)
Sander
 
Posts: 2
Joined: 30 Jan 2008, 19:03

Re: High CPU usage, and a few php warnings

Postby blodan on 03 Feb 2008, 13:25

im going to increase the usleep value to 1000 in beta 0.17, as that doesnt do any noticable change when running the bnc itself and allows more users to use it
User avatar
blodan
Site Admin
 
Posts: 27
Joined: 17 Nov 2007, 00:16

Re: High CPU usage, and a few php warnings

Postby blodan on 15 Feb 2008, 21:39

ive released 0.17-beta now, would be great if you could give me some input on how your cpus is handling it, as i dont have a computer with a cpu lower than 2.8ghz i cant check it out myself :\
User avatar
blodan
Site Admin
 
Posts: 27
Joined: 17 Nov 2007, 00:16


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron


  © 2007-2009 PRAXXA HB, Org. nr 969727-7227 Driven by Daniel Ylitalo & Daniel Lindholm, info@praxxa.com  
  The PRAXXA Network » www.praxxa.com » www.phpBNC.se » www.phpguides.eu » www.phpstuff.org » Nyheter