bergie / dnode-php

DNode RPC protocol implementation for PHP
MIT License
430 stars 86 forks source link

dynamic throttle for main loop #6

Closed skenqbx closed 12 years ago

skenqbx commented 12 years ago

Hello,

while using a php client with node.js server, i stumbled upon 100% cpu usage for the client.

To prevent this behavior for idle clients i added idle checks for empty select() calls, empty $readables and empty $client->requests. If $emptySelectCount hits $emptySelectThreshold the $interval is incremented by $intervalStep and the count is reset.

If the loop checks out, not to be idle, the interval is reset. Otherwise the interval is incremented until it hits $intervalMax.

This patch needs review, and still some means of configuration.

Looking forward to your feedback.