Surprising results with .NET multi-theading algorithm
Posted
by Myles J
on Stack Overflow
See other posts from Stack Overflow
or by Myles J
Published on 2010-01-10T23:17:56Z
Indexed on
2010/05/10
8:34 UTC
Read the original article
Hit count: 440
Hi,
I've recently wrote a C# console time tabling algorithm that is based on a combination of a genetic algorithm with a few brute force routines thrown in. The initial results were promising but I figured I could improve the performance by splitting the brute force routines up to run in parallel on multi processor architectures. To do this I used the well documented Producer/Consumer model (as documented in this fantastic article http://www.albahari.com/threading/part2.aspx#_ProducerConsumerQWaitHandle). I changed my code to create one thread per logical processor during the brute force routines.
The performance gains on my work station were very pleasing. I am running Windows XP on the following hardware:
Intel Core 2 Quad CPU 2.33 GHz 3.49 GB RAM
Initial tests indicated average performance gains of approx 40% when using 4 threads. The next step was to deploy the new multi-threading version of the algorithm to our higher spec UAT server. Here is the spec of our UAT server:
Windows 2003 Server R2 Enterprise x64 8 cpu (Quad-Core) AMD Opteron 2.70 GHz 255 GB RAM
After running the first round of tests we were all extremely surprised to find that the algorithm actually runs slower on the high spec W2003 server than on my local XP work station! In fact the tests seem to indicate that it doesn't matter how many threads are generated (tests were ran with the app spawning between 2 to 32 threads). The algorithm always runs significantly slower on the UAT W2003 server?
How could this be? Surely the app should run faster on a 8 cpu (Quad-Core) than my 2 Quad work station? Why are we seeing no performance gains with the multi-threading on the W2003 server whilst the XP workstation tests show gains of up to 40%?
Any help or pointers would be appreciated.
Regards
Myles
© Stack Overflow or respective owner