Dear God, what am I doing? Concurrency and parallel processing
summary
Compares threads, fibers and forked processes with concrete examples: fetching N Google pages with a queue, four-thread worker pool, and fork+threads which measures fastest for that workload; shows adding threads can slow things due to context switching and MRI’s global interpreter lock preventing true CPU concurrency. Demonstrates a real bug from using non‑blocking queue empty/pop that causes deadlock, explains copy‑on‑write memory cost after fork, and demos Celluloid/DCell (ZeroMQ) with celluloid pools and supervision that restarts crashed workers.
AI-written summary · about
chapters (22)
- 0:00Introduction and motivation
- 1:24Processes threads and fibers
- 3:10Making programs faster
- 5:13Thread basics and joining
- 6:38Shared memory and locks
- 8:03Threads vs processes
- 9:49Fibers overview
- 11:01Fetching Google searches
- 12:25Thread limits and context switching
- 13:50Global interpreter lock
- 14:53MRI vs JRuby Rubinius
- 15:35Multi-process caveats
- 16:59Combining processes and threads
- 17:41Queue deadlock issue
- 20:48Unicorn web server
- 21:51Memory costs of forking
- 23:13Celluloid and actor model
- 25:20Mailbox communication
- 26:46Worker pools in Celluloid
- 27:28Distributed Celluloid
- 28:51Non-blocking I/O overview
- 31:23Q&A and closing
