Just sharing some of my inconsequential lunch conversations with you... RSS  

Saturday, March 29, 2008

Saved by Parallel Extensions!

Let's start by admitting the obvious: normally I don't really need a reason to use a new technology, just doing it for the kicks is good enough for me. I've been using Parallel extensions for a while, but didn't found any real excuse for using it on my typical web projects.

I was lucky enough to get a great R&D project on Search Algorithms, so I've decided to give Parallel Extensions a real try out.

The opportunity arrived while analyzing the log data: we identified a 13 minutes operation. This operation did some heavy computation over a 4 dimension array (well, actually a 2 dimension array of HashTables keyed as duples, the last 2 dimension are sparse). We identified that the dimensions were used independently from each other, and decided to work over a 700 iteration loop.

All we've had to do was changing:

    for (int iterator = 0; iterator < totalIterations; iterator++)

for:

    System.Threading.Parallel.For(0, totalIterations, iterator =>

As expected, we doubled the operation response time. Next week we will be running some tests over an 8-core equipment, so I hope the 13 minutes spent over an old Dual Core will just be pulverized.


The next step in the roadmap will be: grid computing. So lets hope for more lengthy operations so I can get my hands on www.alchemi.net or ngrid.sourceforge.net.


PS: actually, though the loop iteration were independent from each other, they were dependent upon a variable that we had to lock - with little or no performance cost.

No comments:

Development Catharsis :: Copyright 2006 Mário Romano