[Mono-list] Multiple threads slower than multiple processes?

SvenG sgroot at gmail.com
Tue Feb 24 03:32:51 EST 2009


I'm trying to research some threading issues. I've created a simple
application that does word count on a file. That application can create
multiple threads to do multiple word counts in parallel. There is no
communication between the threads; it's just running the exact same thing
multiple times at once.

I'm running that application against a randomly generated 2GB file. If I run
it with 1 thread, this takes about 205 seconds and I'm seeing 100% CPU
usage. If I run two instances of the application simultaneously on the same
system it takes 205 seconds for each, and I'm seeing 200% CPU (100% for each
process).

However, when I use two threads in the same process (which does exactly the
same thing as just running two instances of the application).It takes 290
seconds, a whopping 40% slower! CPU usage is only about 180%, 90% per
thread, and the CPU time consumed by each thread is also more than the CPU
time consumed by the single-thread process.

This strikes me as extremely weird, and is very worrying for what I'm using
Mono for. Is there anyone who can shed some more light on the situation?

Here's the program I'm using: 
http://www.nabble.com/file/p22177940/WordCountTest.cs WordCountTest.cs 

The system I'm testing this on has two Xeon E5410 quad core CPUs (so 8 cores
total in the system). It's running Debian, kernel 2.6.18-6-amd64. Mono 2.2,
compiled from the source tarball.

Any help would be immensely appreciated.
-- 
View this message in context: http://www.nabble.com/Multiple-threads-slower-than-multiple-processes--tp22177940p22177940.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list