tags:

views:

222

answers:

3

I've been tasked to write a high performance, high availability service that will run on a multicore box.

Do I need to make use of Task Parellel Library to really leverage a multicore server or will the service automagically run faster if I throw more hardware (cores) at it? Does the .NET framework provide the magic for me under the covers?

As a corollary, will there be performance gains by upgrading the server with more cores (keeping the spec of each individual core the same) for .NET applications that do not use TPL?

As per my understanding (perusing Joe Duffy's book and his blogs), you really do need to program for multicore. Is my conclusion accurate?

+6  A: 

This is difficult to answer accurately since parallel processing is not a generic problem. You'll need to analyze your project to find places where you can leverage parallel processing.

If your application can be easily broken down into concrete independent tasks, parallel processing will definitely improve. If its primarily serial in nature, multiple cores/threads won't really help at all.

If you've determined that parallel tasks represent the core of your process, a parallel library can help you perform the basic tasks as well as make it easier to get right.

Paul Alexander
Thanks Paul. My application will definitely have certain amount of parallelism and the application will be multithreaded. Will creating threads leverage multicore hardware? Does the framework (or OS?) decide if it can (or should) run a thread on a different core, or do I need to explicitly program for it?
Sprash
Paul Alexander
+3  A: 

Take a look at PLinq which will be coming in .Net 4.0. It will give you a lot of parallel processing capabilities without needing to manage task/load algorithms.

Brian Genisio
Yes, I'm eagerly awaiting PLinq and .NET 4.0. They have done some pretty extensive work in this area. Unfortunately I can't risk alpha version of the framework for production
Sprash
+1  A: 

A program needs to have several paths of execution to leverage anything more than 1 core/processor. Typically this is done by running more than 1 thread, as most OS's only way of providing more than execution path is either by running several processes(executables) or several threads within one process.

There's several high level abstractions built into modern languages to more easily dealing with what is essentially multi-threading, but better learn the basics first; Threads

nos
Yes, my application most certainly be multi-threaded. Will just the act of creating threads leverage multi-core hardware?
Sprash
When you manage to divide up the code that you want to run, to execute in mutiple threads, then yes - the OS will take care of running the threads on different cores.Ofcourse, multithreading needs to be done very carefully, you don't want to end up with race condiftions,deadlocks, data inconsitency etc.
nos