Exploit easily your cores

Microsoft has released it’s Parallel Extensions to the .NET Framework 3.5 as CTP (you can found more about it on Joe Duffy’s Blog). The library provides some interesting features: one is a easy way to execute LINQ queries in parallel and simple loops. The other thing is that a simple to use Task execution library which, and this is the most interesting part, is not build up on the existing ThreadPool class instead a new Scheduler based on “Work-Stealing” is realized. Why is that important? Normally you use threads which have, although not so much, some overhead in creation and management. This plays no role for long running tasks but it is certainly not very effective for very small tasks as they exist if you want, as example, extend a sorting algorithm. On the other side you have often to sync the work of some parallel task so you use resettable events, in C#, and wait for them. The problem is that they are not cheap because they are using actively system resources, e.g. handles, which are somehow limited. The new library does not need event for this job, so the only resources used are the threads you assign to the TaskManager class. This is certainly not a production ready library but a very interesting one because it makes development of effective multi-core aware data structures and algorithms very easy. The Java world has already for some years a library like this: Doug Lea’s Concurrency Library has a Fork/Join framework which is also based on a “Work-Stealing” scheduler but I doubt a lot of people knew about it. The framework will be part of Java 7 which, sorry to say, will not be available until 2009.


No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: