Process Startup: Orders of Magnitude Slower Than Threads

Spawning a new Python process is significantly more resource-intensive, requiring distinct memory space and a full interpreter copy, whereas threads are lightweight, sharing memory and incurring minimal OS overhead.

The top 3

  1. Process vs. Thread Startup: Orders of Magnitude Slower: Creating a new process typically takes hundreds of microseconds to several milliseconds, whereas creating a new thread can be orders of magnitude faster, often completing in tens of microseconds.
  2. Top 3 OS Overheads for Process Creation: The significant overhead of process creation stems from key operating system operations: allocating a new virtual memory space, duplicating (or setting up copy-on-write for) the parent's memory, and initializing a new Process Control Block (PCB) with resources like file descriptors.
  3. Process Overhead: Why It Crushes Fine-Grained Parallelism: The substantial startup cost of processes makes them highly inefficient for fine-grained parallel tasks or those requiring frequent, short-duration execution, where the overhead can easily exceed the actual computation time, favoring lighter threads or asynchronous approaches.

Sources

Open the full topic