BEAM Context Switch: Nanoseconds vs. OS Microseconds
BEAM processes boast context switching times in nanoseconds, significantly faster than typical operating system threads and processes, which incur overheads ranging from 1.2 to over 5 microseconds.
The top 3
- BEAM's Context Switch: User-Space vs. Kernel-Space Advantage: BEAM processes are scheduled and managed entirely within the Erlang Virtual Machine (user-space), significantly reducing overhead by avoiding costly kernel-mode transitions and saving minimal CPU state during switches, unlike OS threads which require kernel intervention.
- Context Switch Latency: BEAM's 100x to 1000x Speed Edge: BEAM's process context switches can occur in tens of nanoseconds (e.g., ~20-100 ns), a dramatic contrast to operating system thread context switches which typically take hundreds of nanoseconds to several microseconds (e.g., 1-10 µs), making BEAM switches up to 1000 times faster.
- BEAM Process State: Minimal Data for Ultra-Fast Switches: Erlang processes are exceptionally lightweight, typically using just 2-3 kilobytes of memory for their state, compared to operating system threads that often require 1-2 megabytes, drastically reducing context switch overhead.
Sources
Open the full topic