metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
210 stars 154 forks source link

Better and tweakable readsleep settings #237

Closed webdevvie closed 4 years ago

webdevvie commented 4 years ago

Allows the ability to turn the read wait time off or tweak the settings for your own system.

I benchmarked this against a local EPP server. Added a 1 second delay to each request (server side) to simulate longer response times to trigger the cpu usage issue.

For reviewer: Please review, run tests and check if this works properly. I have benchmarked and tested this manually but perhaps your unit tests might reveal some issues.

The benchmarking data:

Lower loops = lower cpu usage = better

no usleep

CPU:        99.9%
Hello Loops:    1716
Login Loops:    1528655
Poll Loops: 1477121
Logout Loops:   1361825
Time taken: 3.444s

current (master) sleep at 100 microseconds

CPU:        4.1%
Hello Loops:    9
Login Loops:    8446
Poll Loops: 8654
Logout Loops:   8483
Time taken: 3.430s

current but longer sleep (1ms)

CPU:        2.4%
Hello Loops:    3
Login Loops:    933
Poll Loops: 884
Logout Loops:   868
Time taken: 3.459s

this new branch

CPU:        0.2%
Hello Loops:    3
Login Loops:    80
Poll Loops: 80
Logout Loops:   80
Time taken: 3.444s

This new branch but set Incrementor limit to 50000

CPU:        0.2%
Hello Loops:    3
Login Loops:    47
Poll Loops:     47
Logout Loops:   47
Time taken: 3.529s