8
Most read
10
Most read
14
Most read
Concurrency vs Parallelism
Concurrency is NOT parallelism.
SJ Campus Model
Speed up from 4 minutes to 40 seconds (6 times faster)

If also include Optimisation time, we speed up around 12 times.
Concurrency vs Parallelism
• Rob Pike, the inventor of Go and member of Unix team

• Gave a talk in 2013, when introducing the Go concurrency primitives

• “Concurrency is NOT parallelism”
• https://blog.golang.org/waza-talk
Concurrency vs Parallelism
• The modern world is parallel

• CPU, Network, Users, Workers, etc

• A lot of programming language provides concurrency primitives

• Concurrent execution

• Synchronisation and messaging
Concurrency vs Parallelism
• Concurrency

• Programming as the composition of independently executing
processes.

• Parallelism

• Programming as the simultaneous execution of (possibly related)
computations.
Concurrency vs Parallelism
• Concurrency is about dealing with lots of things at once.

• Parallelism is about doing lots of things at once.

• Concurrency is about structure, parallelism is about execution.

• Concurrency provides a way to structure a solution to solve a problem
that may (but not necessarily) be parallelizable.
Concurrency plus communication
• Concurrency is a way to structure a program by breaking it into pieces
that can be executed independently.

• Communication is the means to coordinate the independent executions.

• CSP (Communicating Sequential Processes), 1978

• https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf
Parallelism example
• Multi-Threading

• Multi-Processing

• Clusters
Parallelism example
Concurrent Dictionary (Meshes, …)
Thread 1: IO, Read and parse data from disk.
Thread 2: loop forever and
if the mesh does not have
collider, attach it.
Thread 3: loop forever and if there
is new mesh instances, merge it.
4 threads used
including main thread.
Problem?
Concurrent Dictionary (Meshes, …)
Thread 1: IO, Read and parse data from disk.
Thread 2: loop forever and
if the mesh does not have
collider, attach it.
Thread 3: loop forever and if there
is new mesh instances, merge it.
Workload: High
Workload: Medium, but
need wait for main thread
Workload: low
Low-level concurrency model is
NOT able to utilise the
computational resources
Problem?
Concurrent Dictionary (Meshes, …)
Thread 1: IO, Read and parse data from disk.
Thread 2: loop forever and
if the mesh does not have
collider, attach it.
Thread 3: loop forever and if there
is new mesh instances, merge it.
Loop forever, busy wait
Workload: low
Loop forever, busy wait
Low-level concurrency model
creates OVERHEAD
Modern Concurrency Model
• Task (promise, coroutine, worker) model

• Thread pool model

• Be able to utilise all computational resources

• Be able to write code in sequential way
Task Model
Concurrent Queue (Tasks…) Push task to the queue
Thread 1: loop forever and
try dequeue, if there is a
task, executes it.
Thread 2: loop forever and
try dequeue, if there is a
task, executes it.
Thread 3: loop forever and
try dequeue, if there is a
task, executes it.
Worker Threads
Thread Pool
Problem?
Concurrent Queue (Tasks…) Push task to the queue
Thread 1: loop forever and
try dequeue, if there is a
task, executes it.
Thread 2: loop forever and
try dequeue, if there is a
task, executes it.
Thread 3: loop forever and
try dequeue, if there is a
task, executes it.
Worker Threads
When thread 1 is busy, thread 2 can
take the task and execute

Be able to utilise all resources (if
there are tasks in the queue)
Problem?
Concurrent Queue (Tasks…) Push task to the queue
Thread 1: loop forever and
try dequeue, if there is a
task, executes it.
Thread 2: loop forever and
try dequeue, if there is a
task, executes it.
Thread 3: loop forever and
try dequeue, if there is a
task, executes it.
Worker Threads
If there is no tasks or just a few
tasks in the queue, we can reduce
the amount of the worker threads.
And increase them when more
tasks come in. (Less overhead)
Dependency?
Concurrent Queue (Tasks…) Push task to the queue
Thread 1: loop forever and
try dequeue, if there is a
task, executes it.
Thread 2: loop forever and
try dequeue, if there is a
task, executes it.
Thread 3: loop forever and
try dequeue, if there is a
task, executes it.
Worker Threads
What if tasks have dependency? i.e.
task 2 must execute after task 1.

We can enqueue task 2 after task 1
finishes.
Priority?
Concurrent Queue (Tasks…) Push task to the queue
Thread 1: loop forever and
try dequeue, if there is a
task, executes it.
Thread 2: loop forever and
try dequeue, if there is a
task, executes it.
Thread 3: loop forever and
try dequeue, if there is a
task, executes it.
Worker Threads
We can use multiple task queues if
task has priority. Or we can create a
special task queue for main thread.
Concurrent Queue (Tasks…)
Concurrent Queue (Tasks…)
Question
• Unity StartCoroutine

• Is it a concurrency model?

• Does it run parallel? 

• How does Unity implement the coroutine? 

• What is the potential issue of the Task model?

More Related Content

PPT
Backtracking Algorithm.ppt
PPTX
Abstract Data Types
DOC
CS8391 Data Structures Part B Questions Anna University
PPT
DATA STRUCTURE AND ALGORITHMS
PDF
Python file handling
PPTX
File Handling Python
PPT
Inter-Process communication in Operating System.ppt
PPT
Abstract data types (adt) intro to data structure part 2
Backtracking Algorithm.ppt
Abstract Data Types
CS8391 Data Structures Part B Questions Anna University
DATA STRUCTURE AND ALGORITHMS
Python file handling
File Handling Python
Inter-Process communication in Operating System.ppt
Abstract data types (adt) intro to data structure part 2

What's hot (20)

PPTX
Query optimization
PDF
Datatypes in python
PPTX
Tree Traversal
PPTX
Python-Inheritance.pptx
PPT
3.9 external sorting
PPTX
STACKS IN DATASTRUCTURE
PPSX
Data Structure (Queue)
PDF
PPTX
Tree traversal techniques
PPTX
Graph traversals in Data Structures
PDF
Quick Sort , Merge Sort , Heap Sort
PPTX
Nested queries in database
PPT
List Data Structure
PDF
Classes and Objects
PPTX
Stack operation algorithms with example
PDF
Searching and Sorting Techniques in Data Structure
PPTX
trigger dbms
PPTX
Python - Numpy/Pandas/Matplot Machine Learning Libraries
PPT
SEARCHING AND SORTING ALGORITHMS
PPT
Thread model in java
Query optimization
Datatypes in python
Tree Traversal
Python-Inheritance.pptx
3.9 external sorting
STACKS IN DATASTRUCTURE
Data Structure (Queue)
Tree traversal techniques
Graph traversals in Data Structures
Quick Sort , Merge Sort , Heap Sort
Nested queries in database
List Data Structure
Classes and Objects
Stack operation algorithms with example
Searching and Sorting Techniques in Data Structure
trigger dbms
Python - Numpy/Pandas/Matplot Machine Learning Libraries
SEARCHING AND SORTING ALGORITHMS
Thread model in java
Ad

Similar to Concurrency vs parallelism (20)

PDF
I see deadlocks : Matt Ellis - Techorama NL 2024
PDF
Concurrency and parallel in .net
PDF
Concurrency, Parallelism And IO
PPTX
.NET Multithreading/Multitasking
PPT
The Pillars Of Concurrency
PPTX
Concurrency in c#
PDF
Concurrency in Python4k
PPTX
Ruby Concurrency
PPTX
parallel-asynchronous-programming-java.pptx
PDF
Highly concurrent yet natural programming
PDF
.Net Threading
PPTX
Seminar on Parallel and Concurrent Programming
PPT
Parallel Programming: Beyond the Critical Section
PPT
cs1311lecture25wdl.ppt
PDF
Need for Async: Hot pursuit for scalable applications
PPTX
Async and parallel patterns and application design - TechDays2013 NL
PPT
Introto netthreads-090906214344-phpapp01
PPT
Intro To .Net Threads
PDF
Sync, async and multithreading
PPT
Parallel Programming and F#
I see deadlocks : Matt Ellis - Techorama NL 2024
Concurrency and parallel in .net
Concurrency, Parallelism And IO
.NET Multithreading/Multitasking
The Pillars Of Concurrency
Concurrency in c#
Concurrency in Python4k
Ruby Concurrency
parallel-asynchronous-programming-java.pptx
Highly concurrent yet natural programming
.Net Threading
Seminar on Parallel and Concurrent Programming
Parallel Programming: Beyond the Critical Section
cs1311lecture25wdl.ppt
Need for Async: Hot pursuit for scalable applications
Async and parallel patterns and application design - TechDays2013 NL
Introto netthreads-090906214344-phpapp01
Intro To .Net Threads
Sync, async and multithreading
Parallel Programming and F#
Ad

Recently uploaded (20)

PPTX
Presentation - Summer Internship at Samatrix.io_template_2.pptx
PDF
solman-7.0-ehp1-sp21-incident-management
PDF
IDM Crack Activation Key 2025 Free Download
PPTX
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
PDF
How to Set Realistic Project Milestones and Deadlines
PDF
Module 1 - Introduction to Generative AI.pdf
PDF
DOWNLOAD—IOBit Uninstaller Pro Crack Download Free
PPTX
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
PDF
Mobile App for Guard Tour and Reporting.pdf
PPTX
Relevance Tuning with Genetic Algorithms
PPTX
oracle_ebs_12.2_project_cutoveroutage.pptx
PDF
IObit Driver Booster Pro Crack Latest Version Download
PDF
OpenEXR Virtual Town Hall - August 2025
PDF
MaterialX Virtual Town Hall - August 2025
PDF
C language slides for c programming book by ANSI
PPTX
MCP empowers AI Agents from Zero to Production
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PPTX
SAP Business AI_L1 Overview_EXTERNAL.pptx
PDF
Difference Between Website and Web Application.pdf
PPTX
Greedy best-first search algorithm always selects the path which appears best...
Presentation - Summer Internship at Samatrix.io_template_2.pptx
solman-7.0-ehp1-sp21-incident-management
IDM Crack Activation Key 2025 Free Download
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
How to Set Realistic Project Milestones and Deadlines
Module 1 - Introduction to Generative AI.pdf
DOWNLOAD—IOBit Uninstaller Pro Crack Download Free
StacksandQueuesCLASS 12 COMPUTER SCIENCE.pptx
Mobile App for Guard Tour and Reporting.pdf
Relevance Tuning with Genetic Algorithms
oracle_ebs_12.2_project_cutoveroutage.pptx
IObit Driver Booster Pro Crack Latest Version Download
OpenEXR Virtual Town Hall - August 2025
MaterialX Virtual Town Hall - August 2025
C language slides for c programming book by ANSI
MCP empowers AI Agents from Zero to Production
ESDS_SAP Application Cloud Offerings.pptx
SAP Business AI_L1 Overview_EXTERNAL.pptx
Difference Between Website and Web Application.pdf
Greedy best-first search algorithm always selects the path which appears best...

Concurrency vs parallelism

  • 2. SJ Campus Model Speed up from 4 minutes to 40 seconds (6 times faster) If also include Optimisation time, we speed up around 12 times.
  • 3. Concurrency vs Parallelism • Rob Pike, the inventor of Go and member of Unix team • Gave a talk in 2013, when introducing the Go concurrency primitives • “Concurrency is NOT parallelism” • https://blog.golang.org/waza-talk
  • 4. Concurrency vs Parallelism • The modern world is parallel • CPU, Network, Users, Workers, etc • A lot of programming language provides concurrency primitives • Concurrent execution • Synchronisation and messaging
  • 5. Concurrency vs Parallelism • Concurrency • Programming as the composition of independently executing processes. • Parallelism • Programming as the simultaneous execution of (possibly related) computations.
  • 6. Concurrency vs Parallelism • Concurrency is about dealing with lots of things at once. • Parallelism is about doing lots of things at once. • Concurrency is about structure, parallelism is about execution. • Concurrency provides a way to structure a solution to solve a problem that may (but not necessarily) be parallelizable.
  • 7. Concurrency plus communication • Concurrency is a way to structure a program by breaking it into pieces that can be executed independently. • Communication is the means to coordinate the independent executions. • CSP (Communicating Sequential Processes), 1978 • https://www.cs.cmu.edu/~crary/819-f09/Hoare78.pdf
  • 8. Parallelism example • Multi-Threading • Multi-Processing • Clusters
  • 9. Parallelism example Concurrent Dictionary (Meshes, …) Thread 1: IO, Read and parse data from disk. Thread 2: loop forever and if the mesh does not have collider, attach it. Thread 3: loop forever and if there is new mesh instances, merge it. 4 threads used including main thread.
  • 10. Problem? Concurrent Dictionary (Meshes, …) Thread 1: IO, Read and parse data from disk. Thread 2: loop forever and if the mesh does not have collider, attach it. Thread 3: loop forever and if there is new mesh instances, merge it. Workload: High Workload: Medium, but need wait for main thread Workload: low Low-level concurrency model is NOT able to utilise the computational resources
  • 11. Problem? Concurrent Dictionary (Meshes, …) Thread 1: IO, Read and parse data from disk. Thread 2: loop forever and if the mesh does not have collider, attach it. Thread 3: loop forever and if there is new mesh instances, merge it. Loop forever, busy wait Workload: low Loop forever, busy wait Low-level concurrency model creates OVERHEAD
  • 12. Modern Concurrency Model • Task (promise, coroutine, worker) model • Thread pool model • Be able to utilise all computational resources • Be able to write code in sequential way
  • 13. Task Model Concurrent Queue (Tasks…) Push task to the queue Thread 1: loop forever and try dequeue, if there is a task, executes it. Thread 2: loop forever and try dequeue, if there is a task, executes it. Thread 3: loop forever and try dequeue, if there is a task, executes it. Worker Threads Thread Pool
  • 14. Problem? Concurrent Queue (Tasks…) Push task to the queue Thread 1: loop forever and try dequeue, if there is a task, executes it. Thread 2: loop forever and try dequeue, if there is a task, executes it. Thread 3: loop forever and try dequeue, if there is a task, executes it. Worker Threads When thread 1 is busy, thread 2 can take the task and execute Be able to utilise all resources (if there are tasks in the queue)
  • 15. Problem? Concurrent Queue (Tasks…) Push task to the queue Thread 1: loop forever and try dequeue, if there is a task, executes it. Thread 2: loop forever and try dequeue, if there is a task, executes it. Thread 3: loop forever and try dequeue, if there is a task, executes it. Worker Threads If there is no tasks or just a few tasks in the queue, we can reduce the amount of the worker threads. And increase them when more tasks come in. (Less overhead)
  • 16. Dependency? Concurrent Queue (Tasks…) Push task to the queue Thread 1: loop forever and try dequeue, if there is a task, executes it. Thread 2: loop forever and try dequeue, if there is a task, executes it. Thread 3: loop forever and try dequeue, if there is a task, executes it. Worker Threads What if tasks have dependency? i.e. task 2 must execute after task 1. We can enqueue task 2 after task 1 finishes.
  • 17. Priority? Concurrent Queue (Tasks…) Push task to the queue Thread 1: loop forever and try dequeue, if there is a task, executes it. Thread 2: loop forever and try dequeue, if there is a task, executes it. Thread 3: loop forever and try dequeue, if there is a task, executes it. Worker Threads We can use multiple task queues if task has priority. Or we can create a special task queue for main thread. Concurrent Queue (Tasks…) Concurrent Queue (Tasks…)
  • 18. Question • Unity StartCoroutine • Is it a concurrency model? • Does it run parallel? • How does Unity implement the coroutine? • What is the potential issue of the Task model?