6 ms·
Concurrency Is Not Parallelism (2013) [video]
- agumonkey 8y agoIsn't parallelism one limit case of concurrency (zero dependencies) and the opposite of full sequentialism (fully dependent) ?
- jmct 8y agoThat's true in one direction, but not the other. The other angle is that concurrent programs are still concurrent on a uni-processor. Parallel programs are not.
- millstone 8y agoWhat is a "concurrent program?" If concurrency is about program structure, does that structure have to be explicit? If I rewrite a loop to support OOE is it thereby concurrent? A uniprocessor may be pipelined, superscalar, support SIMD, etc which would seem to satisfy the definition of parallelism. So isn't parallelism achievable on a uniprocessor? The more I think about this stuff the less sense the distinction makes.
- elteto 8y agoI would define a concurrent program as one with multiple independent flows of execution. Whether they are scheduled on multiple CPUs at the same time or just one is what makes them parallel or not. If you look at a what happens inside a CPU then you probably could say a uniprocessor has some degree of parallelism, but this is not a common point of view AFAIK, it is too low level. Also, the execution contexts inside a pipelined CPU are not entirely independent, you can have pipeline stalls due to dependencies. This is not the case with, say, two application threads running independent tasks.
- gpderetta 8y ago> So isn't parallelism achievable on a uniprocessor? Of course! Normally unqualified parallelism refers to multiprocessor parallelism, but instruction level parallelism is also a thing. So is overlapping io or memory access with computation. Even memory accesses themselves can be parallelized (caches are multi ported, CPUs allow multiple outstanding cache misses), or IO (multiple disks or network cards).
- agumonkey 8y agoFrom what I recall, Quake existed because of instruction level parallelism between apu and fpu. This indeed has importance.
- cultus 8y agoHere's a fantastic set of cartoons explaining concurrency and parallelism: https://typelevel.org/cats-effect/concurrency/basics.html https://typelevel.org/cats-effect/concurrency/basics.html
- realone 8y ago@4:05 people with lesser minds ;)
- justin_vanw 8y agoA distinction isn't necessarily useful.
- Thaxll 8y agoThat's what people using CPython think.
- justin_vanw 8y agoI think most CPython folks are quite annoyed by the lack of concurrent execution! The GIL sucks. If you ever ask Racket-lang folks about threads they will lecture you about concurrency vs parallelism endlessly, it's like a mantra they repeat to avoid realizing there is a problem.
- chrisseaton 8y agoThe GIL prevents parallelism but not concurrency - that’s the whole point of this discussion.
- justin_vanw 8y agoI said concurrent execution. When being pedantic it is important to read carefully. Being super careful about 'parallel' and 'concurrent' is super, super pedantic and pointless. They are synonyms. If two things are running concurrently, they are running in parallel. If two things are running in parallel, they are running concurrently. These are terrible words to overload with very careful definitions. When people talk about 'concurrency' using the super careful pedantic definition, they just mean that it's possible to execute code while at the same time blocking on system calls. This isn't some kind of great feat and any language that can't do it is a toy. There is absolutely no reason to act like 'concurrency' using this definition is in any way special or worth even mentioning. But that's not the point, is it? People get defensive about their favorite languages, so when faced with valid criticisms like "the GIL prevents you from running Python code in parallel" (which is a completely valid and actually pretty huge defect when modern computers have many cores on average) instead of just admitting the deficiency a person can be defensive and respond with stupid lectures about 'concurrency' and 'parallelism'.
- turingspiritfly 8y agoDoesn't Simon Marlow explain the difference very well? Concurrency is implementation detail and parallelism is an execution detail?
- sitkack 8y agoPithy quotes are not wisdom.
- millstone 8y agoConcurrency and parallelism are properties of the resolution with which you view your program. View a program at the distributed system level, vs the OS-scheduled level, vs the microarchitectural superscalar / OoO / SIMD level, and you will come to different conclusions about whether the program is "parallel" and/or "concurrent." These are contextual.
- jzoch 8y agoTo be clear up-front: I agree with you. However, this line of thinking can be a bit disingenuous as it may turn into convincing someone their single threaded program in C is actually multithreaded because of OS scheduling or because it runs on a distributed k8s cluster. It reminds me of how technically there is space between everything if you go small enough (ie cellular or atomic) and how some elementary school kids would use that to convince you that they arent touching you :)
- deleted 8y ago[deleted]
- CoconutPilot 8y agoThe dictionary definition of concurrency contradicts this video. Concurrency is defined as "happening or existing at the same time".
- steamer25 8y agoI think what he means is that he's defining 'concurrent' as a sort of abstract parallelism which can run on 'n' CPU cores. It becomes concrete parallelization when you set n to 2 or more but can still be considered concurrent software architecture even if someone only ever runs their copy with n=1. To address another comment, I agree this distinction has limited utility (assuming I understand it correctly). This context of discussing architectures which promote abstract parallelism is probably about the only place it's useful. I agree that a strict/true interpretation of 'concurrency' (as distinct from Pike's definition) would not include time slice multi-tasking since it depends on the limits of human perception to appear as truly-concurrent/executed-in-parallel when it's actually fine-grained sequential processing.
- gpderetta 8y agoThe difference is instantaneously (parallelism) vs over a period of time (concurrency). Edit: compare a batch system (no concurrency and no parallelism), Vs a time sharing system on an uniprocessor (concurrency) Vs a time sharing system on a multiprocessor (parallelism).
- deleted 8y ago[deleted]
- omazurov 8y agoConcurrency = logical simultaneity. Parallelism = physical simultaneity. When the former is mapped to the latter we encounter scalability. Some examples: Unix commands (cp, grep, awk, sort) do not scale on multi-core systems due to total lack of concurrency in their implementation. Quick sort scales worse than merge sort because the latter allows for more concurrency. A parallel program using a barrier between outer loop iterations (f.e. matrix inversion, or computational partial differential equations) won't scale well because barriers are antithetical to concurrency.
- pmarin 8y ago>Unix commands (cp, grep, awk, sort) do not scale on multi-core systems due to total lack of concurrency in their implementation. This is not true. Unix commands are designed to be used in pipelines. Unix is actually the easiest way to run things in parallel, so easy that people don't even notice.
- dspillett 8y agoThat isn't the individual tools showing concurrency - they are running concurrently due to the way the OS manages processes and pipelines. The overall task has multiple things running concurrently but it doesn't have to[1] and the individual components are doing no concurrency of their own. It has the same effect in many cases because of the buffering built into how pipes are handled, for instance passing the output of gzip through gzip through gzip will happily use most of three cores (if that much CPU time is free at that moment) but try that with commands that need to block such as invocations of sort for example and you'll see that break down. One sort command in your pipeline will tie the whole lot to not scaling much beyond one core[2]. Also pipes and other trickery like xargs/parallel don't help if the task is something like "grep over this large file" - that will only scale over multiple cores at all if your implementation of grep supports a multi-threaded search (and your data is in cache or otherwise in RAM so the process isn't IO-bound). [1] it could queue each and spool the output between to temporary storage, it is so chose [2] note that some implementations of sort, such as the GNU version seen in most (all?) linux distributions, do support their own multi-core use
- 8y ago
- yvdriess 8y agoAfter many years of discussions on the topic, my goto line is now the following: "Parallelism is for performance, Concurrency is for correctness."
- remify 8y agoClean, simple. I like it
- bottled_poe 8y agoThere are several misleading comments here making the incorrect assumption that the term “concurrency” in software has something to do with time. In software design, when we talk about concurrency, we are talking about coordinating distinct logical processes (not necessarily OS processes). This term has limited similarity to the common-knowledge understanding of concurrent events “happening at the same time”. Logical (not temporal) ordering of operations is implemented using process synchronisation techniques. One of the important differences between parallelism and concurrency is that parallelism is typically restricted to almost identical process definitions which aim to exploit the physical architecture of processing units. Concurrency, however, makes fewer assumptions about the physical architecture and focuses on software design in a more abstract way with a primary objective of coordinating resource utilisation of competing processes (especially physical resources).
- ejanus 8y agoWhat is the core difference between Actor and threadpool (Boss/workers)? I do know that this is off-topic, please spare me .