peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.31k stars 201 forks source link

CPU high usage (Socket) #1035

Open Arkantium opened 2 years ago

Arkantium commented 2 years ago

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))

jakubmisek commented 2 years ago

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

Arkantium commented 2 years ago

Yes 1.0.12

jakubmisek commented 2 years ago

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

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

avriltank commented 2 years ago

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