[Mono-devel-list] PATCH: reworked async IO for Socket
Gonzalo Paniagua Javier
gonzalo at ximian.com
Thu Apr 7 00:37:18 EDT 2005
Hi.
The attached files contain patches for Socket.cs and the runtime to
change the way asynchronous IO for sockets work.
Right now, every Begin* on Socket ends up being a work item for the
ThreadPool which limits the number of simultaneous async. operations we
can do to the number of threads in the threadpool which are also used by
delegate async. calls, ASP.NET and HttpWebRequest being hungry consumers
too. This situations leads to frequent deadlocks.
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).
Also bugs #71217 and #71933 are fixed.
No performance differences noticed.
Once this patch is reviewed, I'll make the IO code not to use the
regular thread pool at all by adding a separate mini-pool for IO only.
Btw, I'm accepting suggestions for making socket_io_filter() better when
matching the delegata type.
-Gonzalo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: socket.patch
Type: text/x-patch
Size: 11642 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050407/72eeec93/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: metadata.patch
Type: text/x-patch
Size: 15684 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050407/72eeec93/attachment-0001.bin
-------------- next part --------------
2005-04-07 Gonzalo Paniagua Javier <gonzalo at ximian.com>
* socket-io.h: 2 more fields in MonoSocketAsyncResult.
* threadpool.c: intercept socket async. calls and pass them to a thread
that is polling and dispatching the job items to the threadpool as
socket become ready. Fixes bugs #71217, #71933.
* icall.c: Removed AsyncReceive and AsyncSend. Speed up for copies
between char and short/ushort arrays.
* socket-io.c: remove dead code.
More information about the Mono-devel-list
mailing list