You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project has some potential for additional performance improvements by avoiding a number of unneeded syscalls. These low-level system calls are usually issued as a result of some higher-level PHP function call and have a noticeable performance impact in many cases. Some of these calls are the result of invocations inside this project, some are actually issued lower-level in the Socket or Stream component. As a first step, I'm filing this here to try to start a discussion about this idea.
Here's the strace output with some candidates for removal highlighted:
stream_socket_get_name() (see getpeername() and getsockname()) is called twice only in order to populate the $request->getServerParams() array with REMOTE_ADDR, REMOTE_PORT, SERVER_ADDR and SERVER_PORT. Are these really needed? (See also Add server-side parameters to request object #174, Should the server params always be defined? #192 and others) The remote address could also be reused from the accept() syscall.
Still working out the details, but preliminary benchmark results suggest some noticeable improvements from 19810 req/s to 25032 req/s for the above example on my machine 🔥
This project has some potential for additional performance improvements by avoiding a number of unneeded syscalls. These low-level system calls are usually issued as a result of some higher-level PHP function call and have a noticeable performance impact in many cases. Some of these calls are the result of invocations inside this project, some are actually issued lower-level in the Socket or Stream component. As a first step, I'm filing this here to try to start a discussion about this idea.
Here's the
strace
output with some candidates for removal highlighted:In particular, we may want to avoid the following calls:
stream_set_blocking()
(seeO_NONBLOCK
) is called multiple times through the lifetime of the socket connection. Doing this once should be sufficient.time()
andmicrotime()
(seegettimeofday()
) is called twice only in order to populate the$request->getServerParams()
array withREQUEST_TIME
andREQUEST_TIME_FLOAT
. Are these really needed? (See also Add server-side parameters to request object #174, Should the server params always be defined? #192 and others)stream_socket_get_name()
(seegetpeername()
andgetsockname()
) is called twice only in order to populate the$request->getServerParams()
array withREMOTE_ADDR
,REMOTE_PORT
,SERVER_ADDR
andSERVER_PORT
. Are these really needed? (See also Add server-side parameters to request object #174, Should the server params always be defined? #192 and others) The remote address could also be reused from theaccept()
syscall.fwrite()
(seesendto()
andpselect6()
) will only be called after the stream is reported as writable. We may use an immediate write if the stream is nonblocking. (See also [WIP] Immediate writes to underlying stream until buffer is filled stream#54)The text was updated successfully, but these errors were encountered: