[Mono-devel-list] PATCH: reworked async IO for Socket

Gonzalo Paniagua Javier gonzalo at ximian.com
Fri Apr 8 15:22:46 EDT 2005


On Fri, 2005-04-08 at 11:07 -0700, JD Conley wrote:
> > This patch intercepts the calls before they are added to the thread
> pool
> > and uses a single thread for polling on all the sockets running
> > asynchronous read/write. Once sockets are ready, it dispatches the
> work
> > item to the threadpool which will not be blocked. The patch also
> > serializes read/write calls and allows for multiple Begin* calls on a
> > given socket at the same time (this fails with current mono from SVN).
> 
> This patch is a good start, but this is a fairly serious issue.
> Asynchronous IO is at the heart of high performance, scalable, network
> servers.  Is anyone planning on integrating asynchronous sockets with IO
> Completion Ports (on Windows) and whatever the equivalent is on the
> other platforms?  There has to be a faster way with some kernel level
> asynchronous APIs, rather than playing in user space.

> Of course, maybe I just misunderstood this thread.  I haven't actually
> looked at the code that does this work.

For windows, well, patches for using its asynch. IO functions are
welcome :).

For the rest, aio_(read|write) are not always available and/or
SIGEV_THREAD does not work. Even when SIGEV_THREAD works, the thread
that calls the callback function will be killed if the callback takes
"too much" time, which is not much. So we had to use another thread to
actually invoke the managed callback (and the thread has to be from the
threadpool, to behave like MS).

The code that we have right does not have any performance issue and
works on any system that have select(). And we are just 'wasting' one
thread for polling on all the sockets with ongoing async. operations.

-Gonzalo





More information about the Mono-devel-list mailing list