Boost logo

Boost :

Subject: Re: [boost] Asio - is it possible not to remove descriptor from epoll?
From: Vlad Lazarenko (vlad_at_[hidden])
Date: 2011-03-23 17:27:51


Asio does add-and-remove on every operation which is a bit of a problem
here. Doing reads util the data is exhausted won't help. I think that it can
even hurt because blocking system call will put thread to sleep if there is
no data and also block other consumers running of the same "io_service" (run
() is called by a single thread). In case of multicast, I always get
complete packet (or nothing).

The background is that I have a client application for server(s)
pushing tremendous
amount of data over multicast. Latency is a huge concern (we are talking
sub*micro*seconds). So locking on epoll to add/remove events (or doing
blocking calls) hurts. Basically, I optimized everything - from not calling
"bind" every time, not copying function internals, and re-using the same
pre-allocated memory to store state associated with read. Re-registering
event in epoll is the last thing. I hope to find a way to stick this feature
into Asio or somehow get epoll internals and work with this socket myself.

Thanks,
Vlad

On Wed, Mar 23, 2011 at 4:58 PM, Gruenke, Matt <mgruenke_at_[hidden]> wrote:

> Can't you simply put the descriptor in non-blocking mode and, in your
> async_read handler, perform further non-async reads until the waiting data
> is exhausted? I don't know how ASIO uses epoll, but if it's doing an
> add-and-remove for every async operation, you'd at least get rid of the
> overhead of extra adds & removes while data is still wating.
>
>
> Matt
>
>
> ________________________________
>
> From: boost-bounces_at_[hidden] on behalf of Vlad Lazarenko
> Sent: Wed 3/23/2011 4:27 PM
> To: boost_at_[hidden]
> Subject: [boost] Asio - is it possible not to remove descriptor from epoll?
>
>
>
> Guys,
>
> Is it possible to make ASIO keep descriptor in epoll and not remove it
> automatically after event is fired (and implement or emulate the same
> behavior for other mechanisms like select, kqueue etc)?
> My use case is very simple - I am reading data from multicast socket. One
> read at a time, always reusing the same buffer. The performance is very
> critical. Another use case is to give ASIO a null buffer and perform sync
> read yourself when data is available, in that case you can read from tcp/ip
> sockets as well. I know that libevent supports this but was not able to
> find
> out how to do it with Asio. If it is not available, would someone be able
> to
> assist in adding this feature?
>
> Thank you,
> Vlad
>
> --
> *Vlad Lazarenko*
> *Lazarenko.me <http://lazarenko.me>*
> vlad_at_[hidden] <vlad_at_lazarenko.me>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
*Vlad Lazarenko*
*Lazarenko.me <http://lazarenko.me>*
vlad_at_[hidden] <vlad_at_lazarenko.me>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk