friendica/red

cli_suggest.php runs for a long time and uses huge amounts of RAM

Closed this issue · 3 comments

On Friday, I killed a PHP job that took up 5.9G of RAM and had a CPU time of more than 102 minutes—unfortunately I didn't look at the command line then, I only knew by the user it was executed as that it must have been be the poller or one of the jobs it spawns.

Now I have a job that takes 2.7G of RAM with a CPU time of nearly 35 minutes. Looking at the command line, it says it's php cli_suggest.php.

It's not using much CPU, load is at 0.00 right now, but it eats up memory.

I had a quick look at the code and didn't find anything obvious that would cause this. We don't have servers with millions of users, after all.

EDIT: I think this doesn't happen at every poller call when it runs cli_suggest.php, only sometimes. Maybe when a certain server is asked for its pocos?

Hm, I think I found the culprit.
A host that has been discontinued, but still has xchans in my dircetory, spits out a 301 redirect … to itself. (Currently contacting the admin.) When cli_suggest.php stumbles over that one, it will never return and use more and more memory over time.

Don't know how to fix that myself. z_fetch_url() seems to try to handle that, but it doesn't?

Never mind, found it myself, pull request coming in shortly.

Moved to redmatrix/redmatrix#307