views:

124

answers:

5

I have been asked to show the benefits and limitations of Parallelism and evaluate it for use within our company. We are predominantly a data orientated business, and essentially load objects from the database, then put them through some business logic, display to the user, then save back to the DB. In my mind, there isn't too much in that pipe line that would benefit from running in parallel, but being fairly new to the concept, I could be completely wrong. Would there be any part of that simple pipe line that would benefit from running in parallel? And are there any guidelines for how to implement this style of programming?

Also, are there any tools (preferably that come with VS2010) that would show where bottle necks occur and would be able to visually show what's going on when I click "Go" on a simple app that runs a given amount of loops (pre-written simple maths loops e.g. for i as integer = 1 to 1000 - do some calculations) in parallel, then in series?

I need to be able to display the difference using a decent profiling tool.

+3  A: 

Yes, even from that simple model you could greatly benefit from parrallelism.

Say for instance that during a load of your data you're doing something like this:

foreach(var datarow in someDataSet)
{
    //put your data into some business objects here
}

you could optimize this with parrallelism by doing something like this:

Parrallel.ForEach(someDataSet, datarow =>
{
    //put your data into some business objects here
});

This could greatly increase your performance depending on how much data your processing here.

Each data row will now be processed asynchronously instead of in sequence like the typical foreach loop.

My suggestion to you would be to run some simple performance tests on an example as simple as this one and see what kind of results you get. Plot it out in a spreadsheet or something, and show it to your team. You might be suprised with the results you get.

Joseph
Thanks @Joseph. I had wondered if the Parallel.ForEach would improve even a simple loop of objects. I've created an app that plots out time results based on some loops I have created and run these loops based on cores to run on and whether to run in parallel series and display these on a .Net 4.0 VS2010 Chart. My boss however, wants me to use an existing profiling tool to show whats going on behind the scenes. Is there a tool for showing this effectively?
Ben
@Ben ANTS Profiler is a good tool to check for performance, but it's just one of many. In fact, there are questions on SO about performance tools that would probably have a more complete list for you.
Joseph
+1  A: 

You may reap more benefit from implementing a caching layer (distributed or otherwise) than parallelizing your current pipeline.

With a caching layer, the objects you use frequently will reside in the in-memory cache, allowing for much greater read/write performance. There are a number of options for keeping the cache in sync, and these will vary depending on which vendor you choose.

I'd suggest having a look at MemCached and NCache and see if you think they would be a good fit.

EDIT: As far as profiling tools go, I've used dotTrace extensively and would highly recommend it. You can download a 30 day trial from JetBrains' website.

Winston Smith
A: 

Have you checked out Microsoft's Parallel Computing with Managed Code site? It contains several articles on implementation guidelines discussing both when and how to use .Net 4's parallel features.

Kenneth Baltrinic
A: 

Certainly there are many tasks that can be parallelized, a detailed analysis can help but bottlenecks are possible candidates.
This material can help you Patterns for Parallel Programming: Understanding and Applying Parallel Patterns with the .NET Framework 4

lsalamon
+1  A: 

Possibly, but my general response to this sort of query would typically be - Do you have any performance problems in your application(s)? If yes then by all means investigate why and consider whether parallel execution can help. If not then time is probably best spent elsewhere.

locster