PDC 2009 Day 1: Manycore and .NET 4: A Match Made in Visual Studio 2010

In the PDC session “Manycore and .NET 4: A Match Made in Visual Studio 2010” by Stephan Toub from Microsoft’s Parallel Computing platform, he reviewed all the work done in the concurrency area for the Visual-Studio 2010 and .NET 4.0 release.

Parallel LINQ

Parallel LINQ was not covered in this session as it is covered in a later one, though the “AsParallel()” extension method and “ParallelEnumerable” class were demonstrated.

.NET 4.0 ThreadPool

Many improvements were made to the .NET 4.0 ThreadPool:

  • The global thread pool queue was replaced by a lock-free queue, thus removing a severe bottleneck when moving towards a large number of cores and threads.
  • Local work stealing queues were added for every worker thread. If a worker thread generates additional work items, they are deposited to its own queue in order to not require synchronization with other threads (between related work items) and utilizing cache locality – there’s a good chance that required data is already “hot” in the CPU’s cache between related work items as they generally use the same data. Also note that this work stealing queue is actually stack like – the latest deposited work item is executed first in order to utilize cache locality.
  • When a worker thread doesn’t have a work item in his own queue or in the global queue, it steals work from other threads. The work item that is stolen is the oldest one as it is less likely it has data required for it in the cache already.

Task Parallel Library

ThreadPool.QueueUserWorkItem()” is excellent for fire-and-forget operations, however it does not easily allow waiting, cancelling, joining or other operations on these work items. How can this be achieved? Enter the Task Parallel Library (TPL) and the “Task” class.

The “Task” class can be used to easily create operations that run asynchronously on the ThreadPool and that can be waited on, cancelled etc.

You can read more on Tasks together with code examples in the Parallel Programming Team Blog.

New Sync Primitives in .NET 4.0

Many new synchronization primitives which are used in the TPL and the ThreadPool were made public and are available as part of .NET 4.0 (e.g. “ConcurrentQueue”, “ConcurrentBag” etc.).

Various Profiling & Debugging Features in Visual-Studio 2010

A lot of work went into Visual-Studio 2010 in the area of profiling and debugging concurrent applications in order to make developing these applications much easier. For additional information you can view the article by Stephan and Daniel Moth.

Want to know the gory details and get a more in-depth view?

Come to the SDP and hear Sasha’s and mine session on “Parallel Programming with .NET 4.0 and Visual Studio 2010”.

Comments are closed, but trackbacks and pingbacks are open.