4 ms·
It's always been a better sandbox model, but message passing is still a pain to orchestrate compared to shared-memory data structures.
by sp332 13y ago
It's always been a better sandbox model, but message passing is still a pain to orchestrate compared to shared-memory data structures.
- csmuk 13y agoPersonally I prefer message passing (over pipes). Shared memory (be it shm/heap in same process) with associated mutexes, semaphores, locks and the like is a right pain to get right without introducing race conditions, deadlocks etc. Go is interesting as it uses "micro threads" (goroutines) and message passing CSP style but I haven't found a use for it yet.
- AndrewDucker 13y agoThis is why Mozilla are investing heavily in Rust, so that they can use its semantics to share memory in a safe way.
- pjmlp 13y agoYes, I look forward to the day memory unsafe languages are only part of legacy systems.
- rdtsc 13y ago> Go is interesting as it uses "micro threads" (goroutines) and message passing CSP style but I haven't found a use for it yet. But is also has shared heaps by default. So you still have to rely on everyone being an "adult". I wish shared heaps would have been a specially enabled feature not the default. But I guess the language was position to compete with C++ and Java and isolated heaps would have provided a performance decrease in benchmarks -- and thus people's willingness to adopt it. For large concurrent systems, safety and fault tolerance often leads to their failure but it is kind of hard to encode that in a quick benchmark to impress people. Here are a few languages/systems with default isolated heap runtimes between concurrency units: Dart's isolates, Erlang's processes, Nimrod's threads, Web Workers in modern browsers. Anyone know of more?
- pjmlp 13y agoIn D, by default global data is actually thread local. You need to explicitly enable sharing.
- pcwalton 13y agoBut you can send shared memory between threads and race on it, presumably?
- pjmlp 13y agoYes, but you need to explicitly request it http://dlang.org/migrate-to-shared.html http://dlang.org/migrate-to-shared.html http://www.informit.com/articles/printerfriendly.aspx?p=1609144 http://www.informit.com/articles/printerfriendly.aspx?p=1609...
- csmuk 13y agoMy C code doesn't share heaps. Strict privsep design meaning one heap per process and no threads in favour of "select".
- rdtsc 13y agoWell, OS processes are the obvious solution. I was asking about languages/runtimes that feature that as a default. > and no threads in favour of "select". Not sure why you mentioned that. Callback chains can create concurrency contexts (callback chains) that can interfere with each other, much like multiple threads would. It would have a much higher granularity but you are not out of the woods.
- csmuk 13y agoOnly because I usually end up knocking up network servers. That is true but you only have one thread to synchronise so mutexes and locks are vastly simplified.
- kibwen 13y ago
- nly 13y agoGoing multiprocess and using IPC doesn't intrinsically eliminate any of the tricky concurrency challenges with multi-threading. Neither do coroutines (goroutines). When you have multiple processes talking to another then, unless all your RPCs are completely stateless, you still need to orchestrate synchronisation in some form. There's also the problem that in 2013 we still don't really know how to do IPC/RPCs really well, and doing so portably is hard (Notice Mozilla are writing their own from scratch) It's all very well new languages coming along and solving the trivial stuff (setting up message queues, isolating memory) but very few of them do anything to solve the real problems.
- pjmlp 13y agoTrue, but it does help making the applications more resilient specially if they are stateless. The "let it crash" model from Erlang and micro-kernels. Still you are right, we are far from having an acceptable solution that we could apply everywhere, so to say.
- pcwalton 13y ago> It's all very well new languages coming along and solving the trivial stuff (setting up message queues, isolating memory) but very few of them do anything to solve the real problems. I think that Rust makes a lot of effort to move things in the right direction. In Rust you can share memory, but unless you are in the unsafe sublanguage (which is clearly marked) the type system restricts you to one of: (1) copying messages; (2) transferring ownership of a message so that the original thread cannot race on it; (3) sharing immutable memory only; (4) taking a lock before accessing mutable data. We've seen huge engineering benefits from this: making parts of Servo thread-safe has been simply a matter of running the compiler repeatedly and letting the error messages tell us where to insert the locks; when it compiles we know the data races are gone. (You can still deadlock though.)
- rdtsc 13y agoOn most modern operating system you can selectively set up shared memory between processes as well. One can implement a lower latency (but more dangerous) buffer sharing / message passing-by-reference scheme.
- pjmlp 13y agoThe biggest issue is performance. Although you might be able to work around it with local RPC calls and passing memory ownership as offered by Windows, Mac OS X, QNX and Minix. To quote the ones I am familiar with. Just imagine the performance impact of something like Eclipse if each plugin was a separate process using message passing. Maybe it is doable, not sure. Anyway I rather favor safety over performance.