Parallel vs Concurrent
- Multi core, multiple tasks happening at a single point in time.
- Single core, quickly switching between multiple tasks where only one task is happening at a single point in time.
- CPU Bound
- CPU is working through the problem.
- I/O Bound
- CPU is waiting for the data.
- Native Threads (1:1)
- 1 app thread = 1 OS thread.
- Green Threads (N:M)
- Several virtual threads map to a pool of OS threads.
Efficiency != Performance
Efficiency with Algorithms, Performance with Data Structures - Chandler Carruth
Efficiency = Algorithms
Efficiency is doing less work to get the same result.
Performance = Data Structures
Data Structures allow the CPU pipeline to perform better.
- n=5, bounded, buffered, asynchronous
- Future / Promise
- n=1, bounded, buffered, asynchronous
- Channels, Actor model
- n=0, bounded, unbuffered, synchronous