The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream




    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,652 other followers

Delphi XE7: The new Tasks / Parallel Computing Library. Like any library, it is not a magic bullet!

Posted by jpluimers on 2015/01/01

In Delphi XE7, Embarcadero introduced a new Parallel Computing Library.

Programmers – human as they are – see this as a silver bullet, thinking using such a library will take away all your performance issues without having to know about solving race conditions.

Boy are they wrong. The library helps you, and makes it easier. Easier in the sens of “less hard”.

So here is my friendly warning:

Parallel programming is hard. Live with it.

This apart from another important warning:

Delphi XE7 is the first version where this library is introduced. So expect bugs and more bugs.

This isn’t to say you should not use a library for parallel computing (the OmniThreadLibrary has been around for a reason), just that it is hard to get these right, even for library writers. They often get it right better and faster than rolling your own.

Remember Delphi 6 when TMultiReadExclusiveWriteSynchronizer was introduced and how long it took to flesh out the bugs there?

So here is my last warning:

Parallel computing is that hard. So do use a library, and do so with care. Favour established libraries over new ones.

Then learn to think in the way parallel code works: as much code that can run independently from each other without having to wait. Then learn about how to decouple things (so there is no state, and information can get passed around without the need to wait, i.e. in an asynchronous way).

Thanks to Uwe Raabe, Simon Stuart and Stefan Glienke for reminding me about the first and learning about the second:

This is copied from the New Features (the link is for the youngest Delphi, so when XE8 comes out, it will have different content):

Parallel Computing Library
  • The Parallel Computing library helps you exponentially increases performance making it easier to write multi-threaded applications that take advantage of multi-core CPUs
  • Boost the performance of your existing VCL and FireMonkey applications, with a self-tuning thread pool
  • Include the new System.Threading unit in your apps and you can do the following:
    • Parallel ‘for’ loops
    • Scheduling of tasks
    • Futures
    • Joining of multiple tasks and waiting for all to complete
    • Easy integration for a significant performance boost



PS: What a coincidence: Nick Hodges: Man, the chapter on Multi-threading is going to be seriously hard to write..

5 Responses to “Delphi XE7: The new Tasks / Parallel Computing Library. Like any library, it is not a magic bullet!”

  1. Sir Rufo said

    expect bugs like

  2. Petar said

    Too much bugs I’d say. Embarcadero should have done more extensive tests before releasing PPL in a commercial product. Anyway – good start :)

  3. Rick said


  4. SpeedFreak said

    Good points.
    I’ve always found that if someone thinks threading will make a problem easier to solve, then they haven’t fully understood the problem.

    TMultiReadExclusiveWriteSynchronizer was introduced in Delphi 4 but got a bad rep because the majority of people didn’t understand the inherent danger of read-to-write lock promotion. Unfortunately one of these were Danny Thorpe and late in the D6 beta he completely rewrote the class (and completely broke lock promotion among other things). We’re still using the D5.01 version of TMultiReadExclusiveWriteSynchronizer in several of our systems and it works just fine.

Leave a Reply

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

You are commenting using your 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: