Bug #78825 [Asn->Ver]: stream_socket_client works slower than except
| From: | cmb@php.net | Date: | Thu, 02 Jan 2020 12:34:00 +0000 |
| Subject: | Bug #78825 [Asn->Ver]: stream_socket_client works slower than except | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224664@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78825&edit=1
ID: 78825
Updated by: cmb@php.net
Reported by: vibbow at hotmail dot com
Summary: stream_socket_client works slower than except
-Status: Assigned
+Status: Verified
Type: Bug
Package: Performance problem
Operating System: Windows Server 2019
PHP Version: 7.3.11
-Assigned To: cmb
+Assigned To:
Block user comment: N
Private report: N
New Comment:
In the meantime (for whatever reason) I have been able to
reproduce a noticeable performance difference.
The relevant difference between socket_connect() and the
respective part of stream_socket_client() appears to be that the
latter switches the socket to non-blocking mode before
connect()[1], and then poll()s to wait for the connection to be
established. Since there is no poll() on Windows, an emulation[2]
is used, which might explain the performance difference. However,
if I enforce using the poll emulation on Linux, that's only
marginally slower. If I skip setting the socket non-blocking,
performance is very close to socket_connect(), but doing so would
ignore configured timeouts, and as such is not an option.
Another noteworthy difference is that Windows explicitly calls
shutdown() and poll() before closesocket() is called[3].
This issue certainly deserves further investigation, but doesn't
appear of high priority, so I'm unassigning myself for now. Maybe
someone else has some time to look into this?
[1] <https://github.com/php/php-src/blob/php-7.3.13/main/network.c#L306>
[2] <https://github.com/php/php-src/blob/php-7.3.13/main/network.c#L1197>
[3] <https://github.com/php/php-src/blob/php-7.3.13/main/streams/xp_socket.c#L201-L212>
Previous Comments:
------------------------------------------------------------------------
[2019-12-23 12:24:06] vibbow at hotmail dot com
My server environment is Windows server 2019 (same build number as windows 10 1809) and still can
get this reproduced.
So this issue is not strict to windows 10 1909
------------------------------------------------------------------------
[2019-12-23 12:21:44] cmb@php.net
Thanks for the update! So far I suspect Windows 10 1909 causing
the issue. Will have to check with that version.
------------------------------------------------------------------------
[2019-12-23 12:02:36] vibbow at hotmail dot com
Just tried this on a clean install PC.
Dell Optiplex 3060, with windows 10 1909 x64
Only PHP and VC runtime, no other software
Still can get this reproduced.
https://gist.github.com/vibbow/8909ffc9990023129562e8971fe30f7d
------------------------------------------------------------------------
[2019-11-18 23:03:24] vibbow at hotmail dot com
I can get this reproduced on my laptop without any virtualization software installed, so it's
not virtualizaiton software related issue.
Still try to figure out what's the key point to affect this.
------------------------------------------------------------------------
[2019-11-18 19:51:32] vibbow at hotmail dot com
I'll try to run this test on two physical machine without any virtualization installed.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78825
--
Edit this bug report at https://bugs.php.net/bug.php?id=78825&edit=1