Hey :-)
I spent few hours analyzing PHP's IO multiplexing parts.
IO multiplexing refers to calls to select() / poll() / epoll() or kqueue().
Simple notice : everything is sparse everywhere, we don't have an
IOmux layer designed.
I plan to write an RFC on the subject.
The goal is to centralize IO mux calls in a layer to be used
everywhere. My analyze leads to those points :
- FPM has something, but not designed to be shared
- User streams use hardcoded select() , with an ugly emulation for poll()
- We have nothing about epoll() or kqueue(), except in FPM
-
curl_multi_select()
uses hardcoded select() - php_cli_server uses hardcoded select()
- mysqlnd uses hardcoded select() for its poll() mecanisms
Python already have a layer, at
http://hg.python.org/cpython/file/abcf17bc5eae/Modules/selectmodule.c
Apache's APR has a nice layer with adapters, at
https://github.com/apache/apr/blob/trunk/poll/unix/pollset.c
Still, there exist the excellent libevent http://libevent.org/
So basically, the first question will be do we need it ?
I would say yes. As we are talking about PHP6 and modernising our API,
it is time I think to implement IO mux correctly and don't use the old
select() everywhere where there is a better implementation (epoll and
kqueue are both faster, and they dont suffer from any FD_SETSIZE
limit)
Also, we didnt talk about things as websockets etc... yet, for PHP6 ,
but it is sure that nowadays 2014, IO mux is a must-have.
Second question will be : do we use, and then link against libevent
(or any other lib that could fit the need) , or do we develop our own
layer, based on the FPM layer which is pretty nicely done (just not
shareable elsewhere at the moment).
And then, will people be interested by the RFC ?
Thx,
Julien
So basically, the first question will be do we need it ?
I would like it, yes. Having a IO abstraction layer internally would
be really nice. I'm not up-to-date on all the PHP extensions that
would facilitate this behavior, but perhaps some improved version of
the libuv extensions would be great. I am not sure on the health of
those extensions (I believe there are at least two of them) but it's
worth investigating at least. Potentially it could save us some work
as well as well as give us a bit more confidence.
Second question will be : do we use, and then link against libevent
(or any other lib that could fit the need) , or do we develop our own
layer, based on the FPM layer which is pretty nicely done (just not
shareable elsewhere at the moment).
I also favor libuv over libevent; to be completely fair I have only
used both of them a little bit but I liked libuv a bit more.
We definitely shouldn't roll our own. If we had corporate funding then
rolling our own would have the advantage of not having to wait for
upstream merges for bug fixes, but I don't think we have the manpower
or interest to build and maintain our own.
So basically, the first question will be do we need it ?
I would like it, yes. Having a IO abstraction layer internally would
be really nice. I'm not up-to-date on all the PHP extensions that
would facilitate this behavior, but perhaps some improved version of
the libuv extensions would be great. I am not sure on the health of
those extensions (I believe there are at least two of them) but it's
worth investigating at least. Potentially it could save us some work
as well as well as give us a bit more confidence.Second question will be : do we use, and then link against libevent
(or any other lib that could fit the need) , or do we develop our own
layer, based on the FPM layer which is pretty nicely done (just not
shareable elsewhere at the moment).I also favor libuv over libevent; to be completely fair I have only
used both of them a little bit but I liked libuv a bit more.We definitely shouldn't roll our own. If we had corporate funding then
rolling our own would have the advantage of not having to wait for
upstream merges for bug fixes, but I don't think we have the manpower
or interest to build and maintain our own.
I'm glad there seem to be interest in the subject, I had a good
feeling while writing the mail.
Like Daniel said => IOs is the 2014 bottleneck , and as you can see
from my analyze of the current situation, we have all but a clean IO
API.
I'm gonna start writing the draft RFC this week so that the ideas are
tied into a single place.
I'll be able to invest some time developping such a layer. Feel free
to ping on IRC or intern@ls if one wants to join the effort.
The idea will then be to create a branch for some experiment.
I'm not confident about threads. Threads is another topic (which
shares some comon technical ideas with IOs, such as locking) , and I
think we should treat threads in an other RFC
Julien Pauli
Hey :-)
Hello :-),
I spent few hours analyzing PHP's IO multiplexing parts.
IO multiplexing refers to calls to select() / poll() / epoll() or kqueue().
Simple notice : everything is sparse everywhere, we don't have an
IOmux layer designed.I plan to write an RFC on the subject.
The goal is to centralize IO mux calls in a layer to be used
everywhere. My analyze leads to those points :
- FPM has something, but not designed to be shared
- User streams use hardcoded select() , with an ugly emulation for poll()
- We have nothing about epoll() or kqueue(), except in FPM
curl_multi_select()
uses hardcoded select()- php_cli_server uses hardcoded select()
- mysqlnd uses hardcoded select() for its poll() mecanisms
Python already have a layer, at
http://hg.python.org/cpython/file/abcf17bc5eae/Modules/selectmodule.cApache's APR has a nice layer with adapters, at
https://github.com/apache/apr/blob/trunk/poll/unix/pollset.cStill, there exist the excellent libevent http://libevent.org/
What about depending on libuv also https://github.com/joyent/libuv? It
would offer nice major features.
(Another related link: https://github.com/chobie/php-uv)
So basically, the first question will be do we need it ?
I would say yes. As we are talking about PHP6 and modernising our API,
it is time I think to implement IO mux correctly and don't use the old
select() everywhere where there is a better implementation (epoll and
kqueue are both faster, and they dont suffer from any FD_SETSIZE
limit)
Also, we didnt talk about things as websockets etc... yet, for PHP6 ,
but it is sure that nowadays 2014, IO mux is a must-have.Second question will be : do we use, and then link against libevent
(or any other lib that could fit the need) , or do we develop our own
layer, based on the FPM layer which is pretty nicely done (just not
shareable elsewhere at the moment).And then, will people be interested by the RFC ?
I do.
Cheers.
--
Ivan Enderlin
Developer of Hoa
http://hoa-project.net/
PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/
Member of HTML and WebApps Working Group of W3C
http://w3.org/
I think we do need this and RFC will is needed.
And Daniel Lowrey just sold the libuv as the go to library with his message
I think :)
Hi!
Second question will be : do we use, and then link against libevent
(or any other lib that could fit the need) , or do we develop our own
layer, based on the FPM layer which is pretty nicely done (just not
shareable elsewhere at the moment).And then, will people be interested by the RFC ?
This would be pretty interesting. I wonder though how libevent behaves
on systems like Windows or more exotic Unix variants PHP is know to run
on. In any case, basing it on some mature library would definitely make
sense.
Thanks,
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227