mail-archives/mono-bugs/2010-October/104591.html

178 строки
6.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 644428] New: Mono creates new thread for each call to Socket.xxxAsync
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20644428%5D%20New%3A%20Mono%20creates%20new%20thread%20for%20each%20call%0A%20to%20Socket.xxxAsync&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="104590.html">
<LINK REL="Next" HREF="104612.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 644428] New: Mono creates new thread for each call to Socket.xxxAsync</H1>
<B>bugzilla_noreply at novell.com</B>
<A HREF="mailto:mono-bugs%40lists.ximian.com?Subject=%5BMono-bugs%5D%20%5BBug%20644428%5D%20New%3A%20Mono%20creates%20new%20thread%20for%20each%20call%0A%20to%20Socket.xxxAsync&In-Reply-To="
TITLE="[Mono-bugs] [Bug 644428] New: Mono creates new thread for each call to Socket.xxxAsync">bugzilla_noreply at novell.com
</A><BR>
<I>Thu Oct 7 00:14:25 EDT 2010</I>
<P><UL>
<LI>Previous message: <A HREF="104590.html">[Mono-bugs] [Bug 644418] New: DataTable clone fails
</A></li>
<LI>Next message: <A HREF="104612.html">[Mono-bugs] [Bug 644428] Mono creates new thread for each call to Socket.xxxAsync
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#104591">[ date ]</a>
<a href="thread.html#104591">[ thread ]</a>
<a href="subject.html#104591">[ subject ]</a>
<a href="author.html#104591">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=644428">https://bugzilla.novell.com/show_bug.cgi?id=644428</A>
<A HREF="https://bugzilla.novell.com/show_bug.cgi?id=644428#c0">https://bugzilla.novell.com/show_bug.cgi?id=644428#c0</A>
Summary: Mono creates new thread for each call to
Socket.xxxAsync
Classification: Mono
Product: Mono: Class Libraries
Version: 2.8.x
Platform: All
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
ReportedBy: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">tobias.peciva at kaseya.com</A>
QAContact: <A HREF="http://lists.ximian.com/mailman/listinfo/mono-bugs">mono-bugs at lists.ximian.com</A>
Found By: Development
Blocker: No
Description of Problem:
In .NET 3.5, Microsoft introduced the SocketAsyncEventArgs (SAEA) mechanism in
System.Net.Sockets. The idea was to improve performance for socket servers with
very high throughput, primarily by reusing SAEA objects instead of reallocating
and garbage collecting EventArgs objects for every send/receive/accept request.
The mechanism is outlined here:
<A HREF="http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx">http://msdn.microsoft.com/en-us/library/system.net.sockets.socketasynceventargs.aspx</A>
Here's a variation:
<A HREF="http://www.codeproject.com/KB/IP/socketasynceventargssampl.aspx">http://www.codeproject.com/KB/IP/socketasynceventargssampl.aspx</A>
We have tested this on Windows with .NET 3.5 and 4.0, and it does indeed offer
very high throughput with minimal GC activity. However, under Mono (we use
Ubuntu 64, but this probably applies to all platforms), SAEA performance is
weak. The reason for this appears to be that for every single
SendAsync/ReceiveAsync/AcceptAsync request, Mono creates a new thread. So in
other words, if you have 1,000 clients connected, and you're waiting for data
from all of them, you'll have 1,000 threads.
This is particularly problematic for servers that need to support a large
number of concurrently connected clients, such as XMPP servers (XMPP servers
commonly support 100k+ concurrent clients, with some going as high as 500k+).
Steps to reproduce the problem:
1. Build the sample code provided in the links above.
2. Create a test client that makes e.g. 10k concurrent connections to the
server.
3. Use e.g. &quot;top&quot; to review the number of running threads on the server.
Actual Results:
Mono appears to have as many threads as open connections - plus a few. For
1,000 threads, it's still possible to get somewhat acceptable performance. But
for 20k or more, our Ubuntu 64 systems grind to a halt and become practically
unusable.
Expected Results:
&gt;<i>From our testing, the Windows SAEA implementation can easily handle 200k
</I>concurrent connections (with intermittent traffic) on a moderately specced
machine. We suspect the limit is much, much higher, but we haven't tested this
as we only have 8 client machines available to generate connections.
I don't know exactly how SAEA is implemented in .NET, but I suspect there is a
single IO completion port for all connections, serviced by threads in the
system thread pool. I would expect Mono to do something similar: Use a single,
global IOCP or poll/epoll set, add all file descriptors to this, and use thread
pool threads to dispatch IO completions.
--
Configure bugmail: <A HREF="https://bugzilla.novell.com/userprefs.cgi?tab=email">https://bugzilla.novell.com/userprefs.cgi?tab=email</A>
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="104590.html">[Mono-bugs] [Bug 644418] New: DataTable clone fails
</A></li>
<LI>Next message: <A HREF="104612.html">[Mono-bugs] [Bug 644428] Mono creates new thread for each call to Socket.xxxAsync
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#104591">[ date ]</a>
<a href="thread.html#104591">[ thread ]</a>
<a href="subject.html#104591">[ subject ]</a>
<a href="author.html#104591">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-bugs">More information about the mono-bugs
mailing list</a><br>
</body></html>