Code Watch: Three building blocks for parallel systems
December 15, 2011 —
(Page 1 of 3)
While there is no solution to concurrency in sight, there are three programming abstractions, which have become near-universal building blocks for highly parallel systems: data-parallel loops, Actors, and Futures.
Data-parallel loops are the simplest parallelism that could possibly work. Essentially, they just farm out each loop iteration to a separate thread. This is an expensive operation compared to looping, but if the loop's body is a performance bottleneck, the performance gained by distributing it across cores or processors can be close to linear (there will always be a little overhead). It's important that each loop be independent, which may entail some refactoring of loop-carried dependencies, but, in general, there's nothing not to like about this approach. Data-parallel looping constructs are universally available in mainstream languages.
Actors are objects that, conceptually, run in their own thread (conceptually because system-level threads are typically rather expensive to create and limited in availability, so Actors are usually implemented on top of a fairly complex thread pool provided by the language runtime). A normal Object embodies the only functions that can access that object's non-public data, and that makes reasoning about the data's meaning and validity easier than otherwise. An Actor embodies the only thread that can access that object's non-public members, with similar benefits to reasoning about concurrency. This is so logical that when I first learned OOP, I was surprised to find out it wasn't the norm.
The Actor has a function that loops, reacting to lightweight messages and posting them to the outside world. This is almost always referred to as a mailbox metaphor, but I like to call it a WinMain, just to provoke a reaction (unfortunately, it's getting to the point where not everyone gets the reference). Deep thinkers argue about subtleties of the mailbox (particularly, whether its guarantees about message delivery and ordering are wise or foolish), but if you've programmed Windows in C (or a similar architecture), you know the pattern. You also know how it can break down, with hard-to-debug situations where the troublesome program state is encoded somewhere out there in a gazillion message queues.
Related Search Term(s): concurrency
Share this link: http://sdt.bz/36196
Most Read Latest News Blog Resources
Android is the focus of two new design tools
Anywhere Software and Xamarin provide ways for developers to create and test their applications on PCs
|
|
LEADTOOLS HTML5 add-on modules released
Including New HTML5 Zero Footprint Viewer, JavaScript Libraries and RESTful Web Services for Document and Medical SDKs
|
|
How to speed up your Cukes
Using a five-step process derived from Six Sigma, Cucumber tests can go much faster
|
|
WhiteSource offers open-source license management as a service
Software gives companies insight into the open-source components in products
|
SmartBear rolls out new quality solution: API Complete
Software gives organizations ability to write test scripts and monitor APIs by bridging the DevOps divide
|
|
Android is the focus of two new design tools
Anywhere Software and Xamarin provide ways for developers to create and test their applications on PCs
|
|
WhiteSource offers open-source license management as a service
Software gives companies insight into the open-source components in products
|
|
Top five devices you can integrate with your applications
A five-fingered list of common, household items with which you can talk to (via software, of course)
|
Slick...but who needs it?
compilr.com is a well-designed site and the folks behind it seem to have their heart in the right place. But...who needs it?
|
|
How to be a better software developer
Want to be a better developer? You won't get there by mastering an interesting language or learning a new set of APIs.
|
|
Wooing Galatea
Do yourself a favor and check out Galatea 2.2, a wonderful book by novelist Richard Powers.
|
|
The world as story
An artificial-intelligence system at Carnegie Mellon seeks to understand the world by making statements about it.
|
Five SCM Best Practices
Two-thirds of all software projects fail, according to the Standish Group’s CHAOS study. Improper usage of software configuration management...
|
|
|
Best Practices for Branching and Merging Patterns
Development teams often create a branching pattern, usually drawn out on a white board or in a Visio document, that is used as a model to...
|
|
Automated Error Reporting
We invite you to read a short e-zine that tells you all about automated error reporting for .NET applications. This 8-page e-zine is packed...
|
|
The End of Application Redeploys
Imagine that every time you wanted to write, send or receive an email, you needed to restart your computer. How much time would this take, a...
|