peachpie icon indicating copy to clipboard operation
peachpie copied to clipboard

CPU high usage (Socket)

Open Arkantium opened this issue 3 years ago • 4 comments

Hi !

I have problem of high CPU usage with:

while ($clientSocket = @stream_socket_accept($this->serverSocket, 0)) 46% of the cpu usage

image

PS: No high cpu usage with stream_socket_accept($this->serverSocket, 0.1))

Arkantium avatar Jan 25 '22 10:01 Arkantium

Hi,

Do you use the latest PeachPie 1.0.12 or a previous version? (this has been recently updated by https://github.com/peachpiecompiler/peachpie/pull/1029)

Thanks

jakubmisek avatar Jan 25 '22 10:01 jakubmisek

Yes 1.0.12

Arkantium avatar Jan 25 '22 13:01 Arkantium

weird; it basically does not do anything if parameter is 0;

isn't it called in a loop in your code or something?

jakubmisek avatar Jan 25 '22 14:01 jakubmisek

when set to 0,you may need an eventlloop engine for performance,you just register an event to the loop.Because now the accept dot not wait in a block.There is a stream_select function you can use

avriltank avatar Jan 25 '22 18:01 avriltank