[Mono-bugs] [Bug 75239][Nor] Changed - Processes creating threads
have long pauses.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Aug 28 15:31:01 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by jan.oravec at 6com.sk.
http://bugzilla.ximian.com/show_bug.cgi?id=75239
--- shadow/75239 2005-08-28 13:59:58.000000000 -0400
+++ shadow/75239.tmp.23649 2005-08-28 15:31:01.000000000 -0400
@@ -1714,6 +1714,67 @@
user time: 302 6
------- Additional Comments From bmaurer at users.sf.net 2005-08-28 13:59 -------
Please paste teh C code for comparison. It'd also be interesting to
look at the difference between .net and the w32api for a similar test.
+
+------- Additional Comments From jan.oravec at 6com.sk 2005-08-28 15:31 -------
+The testing machine is PIII 1GHz.
+
+Here is the C code:
+
+
+#include <pthread.h>
+#include <stdlib.h>
+
+void *thr(void *x __attribute((unused)))
+{
+ return NULL;
+}
+
+
+int main()
+{
+ pthread_t *x=malloc(10000*sizeof(pthread_t));
+
+ int i, j, err=0;
+
+ for(i=0; i<100; ++i)
+ {
+ for(j=0; j<10000; ++j)
+ err|=pthread_create(x+j, NULL, thr, NULL);
+
+ for(j=0; j<10000; ++j)
+ err|=pthread_join(x[j], NULL);
+ }
+
+ return err;
+}
+
+
+My observations:
+
+C mmap()s only 256K stack per every thread (probably because ulimit -s
+shows 256K). I have never seen more than 20 active threads at single
+moment. Adding usleep(10000) to the thr() makes it system:48s,
+user:9s, 1000s of threads visible at single moment.
+
+C# mmap()s 1M stacks, but appears to recycle them for further threads.
+Always under 200 active threads. Adding Thread.Sleep(10) made it work
+for some time with responsive system and after few second of running
+some threshold was met and system stopped to be responsive (probably
+~3000 threads which occupied all 3G of user-space address space).
+
+C appears not do make any other system calls per created thread as:
+1. mmap stack memory
+2. mprotect low 4K of stack
+3. make thread with clone()
+4. pair of futex wait/wake to join the thread
+
+C# seems to do a lot of futex communication per created thread and
+gettimeofday() and time() system calls.
+
+The above observations are responsible mainly for increased system
+time in C#. It would be interesting to know what causes that huge
+difference in user time.
+
More information about the mono-bugs
mailing list