Message Passing Leads to Better Scalability in Parallel Systems

Message Passing Leads to Better Scalability in Parallel Systems

Russel Winder

PROGRAMMERS ARE TAUGHT from the very outset of their study of computing that concurrency—and especially parallelism, a special subset of concurrency— is hard, that only the very best can ever hope to get it right, and even they get it wrong. Invariably, there is great focus on threads, semaphores, monitors, and how hard it is to get concurrent access to variables to be thread-safe.

True, there are many difficult problems, and they can be very hard to solve. But what is the root of the problem? Shared memory. Almost all the problems of concurrency that people go on and on about relate to the use of shared mutable memory: race conditions, deadlock, livelock, etc. The answer seems obvious: either forgo concurrency or eschew shared memory!

Forgoing concurrency is almost certainly not an option. Computers have more and more cores on an almost quarterly basis, so harnessing true parallelism becomes more and more important. We can no longer rely on ever-increasing processor clock speeds to improve application performance. Only by exploit- ing parallelism will the performance of applications improve. Obviously, not improving performance is an option, but it is unlikely to be acceptable to users.

So can we eschew shared memory? Definitely.

Instead of using threads and shared memory as our programming model, we can use processes and message passing. Process here just means a protected independent state with executing code, not necessarily an operating system process. Languages such as Erlang (and occam before it) have shown that

??114 97 Things Every Programmer Should Know

?

???????????????processes are a very successful mechanism for programming concurrent and parallel systems. Such systems do not have all the synchronization stresses that shared-memory, multithreaded systems have. Moreover, there is a formal model—Communicating Sequential Processes (CSP)—that can be applied as part of the engineering of such systems.

We can go further and introduce dataflow systems as a way of computing. In a dataflow system, there is no explicitly programmed control flow. Instead, a directed graph of operators, connected by data paths, is set up and then data is fed into the system. Evaluation is controlled by the readiness of data within the system. Definitely no synchronization problems.

That said, languages such as C, C++, Java, Python, and Groovy are the prin- cipal languages of systems development, and all of these are presented to programmers as languages for developing shared-memory, multithreaded systems. So what can be done? The answer is to use—or, if they don’t exist, create—libraries and frameworks that provide process models and message passing, avoiding all use of shared mutable memory.

All in all, not programming with shared memory, but instead using message passing, is likely to be the most successful way of implementing systems that harness the parallelism that is now endemic in computer hardware. Perhaps bizarrely, although processes predate threads as a unit of concurrency, the future seems to be in using threads to implement processes.

时间: 2024-10-28 20:28:22

Message Passing Leads to Better Scalability in Parallel Systems的相关文章

hdu 4661 Message Passing(树形DP&组合数学)

Message Passing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1187    Accepted Submission(s): 423 Problem Description There are n people numbered from 1 to n. Each people have a unique mes

hdu 4661 Message Passing (思维 dp求拓扑排序数)

Message Passing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1184    Accepted Submission(s): 420 Problem Description There are n people numbered from 1 to n. Each people have a unique mes

消息传递(Message Passing)

通常可用把并行程序理解为一组相互独立的.能够发关和接收消息的组件,这也称为角色模型(ActorModel),在维基百科上可找到更正式的解释 http://en.wikipedia.org/wiki/Actor_model.虽然使用消息传递的场景往往相当复杂,但是其背后的思想却相对简单,正像下面将要看到的示例一样: 消息传递背后的基本思想是这样的,系统是由代理(agents)或角色(actors)组合面成的,它们都可以发送和接收消息.当代理接收消息时,这个消息被放在队列(queue)中,直到这个代

chrome extension message passing 消息传递

Chrome插件开发笔记 360翻译了Chrome插件开发的文档   (仍然建议出去看看) 看这里http://open.chrome.360.cn/extension_dev/overview.html 什么是扩展 一个应用(扩展)其实是压缩在一起的一组文件,包括HTML,CSS,Javascript脚本,图片文件,还有其它任何需要的文件. 应用(扩展)本质上来说就是web页面,它们可以使用所有的浏览器提供的API,从XMLHttpRequest到JSON到HTML5全都有. 扩展extens

ARTS Week 18

Feb 24, 2020 ~ Mar 1, 2020 Algorithm Problem 371. Sum of Two Integers(两整数之和) 题目链接 题目描述:给定两个数字,求两个数字之和.不能使用加法运算 思路为:不能使用加法运算,那么可以考虑使用位运算来实现加法.先观察只有一位数的情况: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0(进位为 1) 这个特性符合异或运算,那么可以通过异或运算来实现无进位加法,那么该如何计算进位呢?我们知道,二进制

Passing the Message 单调栈两次

What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten are prepared to have an excursion. Before kicking off, teacher Liu tells them to stand in a row. Teacher Liu has an important message to announce, but s

Notes of Principles of Parallel Programming - partial

0.1 TopicNotes of Lin C., Snyder L.. Principles of Parallel Programming. Beijing: China Machine Press. 2008. (1) Parallel Computer Architecture - done 2015/5/24(2) Parallel Abstraction(3) Scable Algorithm Techniques(4) PP Languages: Java(Thread), MPI

You Probably Don’t Need a Message Queue

原文地址 I’m a minimalist, and I don’t like to complicate software too early and unnecessarily. And adding components to a software system is one of the things that adds a significant amount of complexity. So let’s talk about message queues. Message Queu

Java性能提示(全)

http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLists and ArrayLists (and Vectors) (Page last updated May 2001, Added 2001-06-18, Author Jack Shirazi, Publisher OnJava). Tips: ArrayList is faster than