[beast] write_some EWOULDBLOCK/EAGAIN error recovery non-blocking operations
Have been Beast tested with non blocking sockets? I hadn't found a single reference to asio's non_blocking_io? One of the common use cases is when I want to push a small message to stream (chunk). In 99% of cases the operation will not block so I want to handle this as an optimization for not returning to even loop and creating a callback. According to the reference I didn't find how write_some will behave? I expect to get EWOULDBLOCK kind of error and start asynchronous operation. However I didn't find any reference to the code to non_blocking_io so I wonder if it is supported at all. On same note - how do I run unit tests using b2 - Beast ins't fully Boostified which BTW is also bothering me. Artyom
On Mon, Jul 3, 2017 at 1:10 PM, Artyom Beilis via Boost
Have been Beast tested with non blocking sockets? I hadn't found a single reference to asio's non_blocking_io?
I have not done any work at all with non blocking sockets, although that is on my todo. Specifically to make programs work which use the reactor model rather than the proactor model. This means boost::asio::null_buffers to take the place of "select".
On same note - how do I run unit tests using b2 - Beast ins't fully Boostified which BTW is also bothering me.
The tests run fine for me just run b2 at the root of the Beast directory. The Jamfiles get tested in every CI push, see: https://travis-ci.org/vinniefalco/Beast/jobs/248185459#L1123 Boost.Build was the first build system that Beast used, CMake came after. Both are supported. Thanks
On Mon, Jul 3, 2017 at 11:13 PM, Vinnie Falco via Boost
On Mon, Jul 3, 2017 at 1:10 PM, Artyom Beilis via Boost
wrote: Have been Beast tested with non blocking sockets? I hadn't found a single reference to asio's non_blocking_io?
I have not done any work at all with non blocking sockets, although that is on my todo. Specifically to make programs work which use the reactor model rather than the proactor model. This means boost::asio::null_buffers to take the place of "select".
I strongly recommend doing full testing of everything in non-blocking mode because (a) It is VERY common to mix them so you MUST work correctly regardless the socket configuration. (b) It provides a huge performance advantage especially for small blocks over multiple connections since it reduces need for callback Artyom
On Mon, Jul 3, 2017 at 1:18 PM, Artyom Beilis via Boost
I strongly recommend doing full testing of everything in non-blocking mode because (a) It is VERY common to mix them so you MUST work correctly regardless the socket configuration. (b) It provides a huge performance advantage especially for small blocks over multiple connections since it reduces need for callback
Oh trust me, I know. A carefully written non-blocking mode server can handle thousands of connections and in the fast-path requires resources proportional to N = the number of threads rather than the number of connections. So I will be doing what I can to make this work and make it part of the public interface. Note however, that Beast as proposed does not make any claims at all about whether or not non-blocking socket modes will work.
On 4/07/2017 08:21, Vinnie Falco wrote:
On Mon, Jul 3, 2017 at 1:18 PM, Artyom Beilis
I strongly recommend doing full testing of everything in non-blocking mode because (a) It is VERY common to mix them so you MUST work correctly regardless the socket configuration. (b) It provides a huge performance advantage especially for small blocks over multiple connections since it reduces need for callback
Oh trust me, I know. A carefully written non-blocking mode server can handle thousands of connections and in the fast-path requires resources proportional to N = the number of threads rather than the number of connections. So I will be doing what I can to make this work and make it part of the public interface.
It's unfortunate that (as I understand it) async I/O on Linux isn't implemented very well. Async I/O on Windows is significantly superior to non-blocking I/O, and if it were the same on Linux then you would just never use non-blocking I/O at all (since after all it's mostly a hack anyway).
בתאריך 4 ביולי 2017 3:23 לפנה״צ, "Gavin Lambert via Boost" < boost@lists.boost.org> כתב: On 4/07/2017 08:21, Vinnie Falco wrote:
On Mon, Jul 3, 2017 at 1:18 PM, Artyom Beilis
I strongly recommend doing full testing of everything in non-blocking
mode because (a) It is VERY common to mix them so you MUST work correctly regardless the socket configuration. (b) It provides a huge performance advantage especially for small blocks over multiple connections since it reduces need for callback
Oh trust me, I know. A carefully written non-blocking mode server can handle thousands of connections and in the fast-path requires resources proportional to N = the number of threads rather than the number of connections. So I will be doing what I can to make this work and make it part of the public interface.
It's unfortunate that (as I understand it) async I/O on Linux isn't implemented very well. Async I/O on Windows is significantly superior to non-blocking I/O, and if it were the same on Linux then you would just never use non-blocking I/O at all (since after all it's mostly a hack anyway). Actually on the contrary. On most Unix like platforms you can do both reactor and proactor style of operations efficiently. epoll, /dev/poll and kqueue based operations can be simply transformed into proactor operations while competition port is limited to proactor operations only. The major difference is when you can complete the operation immediately you don't want to pay the price for callback as callback has a significant price. that's why non blocking operations are so useful Artyom
participants (4)
-
Artyom Beilis
-
Gavin Lambert
-
Peter Dimov
-
Vinnie Falco