BEAM's Secret: User-Space Scheduling Avoids Costly Kernel Calls
Unlike OS threads managed by the kernel, BEAM processes are scheduled and context-switched entirely within the Erlang Virtual Machine (BEAM) in user space. This bypasses the heavy overhead of kernel calls and saving/restoring the full CPU state, only preserving essential registers.
The top 3
- User-Space Scheduling: Nanosecond vs. Microsecond Gap: BEAM's user-space context switching operates in the hundreds of nanoseconds, offering a dramatic speed advantage over traditional OS kernel context switches which typically range from 1 to 10 microseconds by bypassing expensive kernel calls.
- Erlang's Telecom Roots Drove User-Space Scheduling: BEAM's user-space scheduling was a direct outcome of Erlang's origins at Ericsson in the 1990s, designed to meet the demanding requirements for fault-tolerant, massively concurrent, and soft real-time telecom systems.
- Millions of Processes: BEAM's Scalability Edge: By managing processes entirely within its runtime, BEAM's user-space scheduling allows a single Erlang VM to efficiently support millions of lightweight, isolated processes, a scale far beyond what typical OS threads can achieve.
Sources
Open the full topic