Saturday, April 26, 2008

Parallelism, Concurrency and the free lunch

For anybody who is looking for ways of how to take advantage of the CPU capability to make their program run faster, I would suggest to look at the Parallel Framework Extension and download the PFX CTP to try it out.

I was just optimizing my program. On my dual core machine, the improved version of my program which use PFX give me an approximate of 18% performance improvement over the original program which use a conventional foreach loop. As my data set increase, the gain is up to about 35%.

Why this is a big deal?

As the silicon has reach its physics limit of getting more into the CPU chip, we cannot depend on Moore’s law to take care of performance for us anymore. The free lunch is pretty much over.

Instead, we can see emerging trend in parallelism and concurrency. People today are talking about multi core processors and how to make program run faster by utilizing all the cores they have in the computer; functional programming language is getting more attention; functional programming elements start to incorporated into mainstream imperative language (example is Linq); Software Transactional Memory is also getting more research effort.

I bet that concurrency is going to be one of the important topics in the next wave of programming paradigm.

Having say that, I dont mean concurrency is the ultimate to all problems. Concurrency is a tough subject and hard to get it right. You have to weight whether the overhead of locking is worth the benefits; You have to understand the side effects of state changes; You have to find a way to handle exception and etc. Concurrency is mean to be a way of tapping into the spare processing capacity, not a way to make slow code fast. You still have to understand where the bottleneck is in your code before you decide to settle on making things more concurrent. Use it with care.

Labels:

0 Comments:

Post a Comment

<< Home