The BEAM Scheduler's Non-Preemptive Advantage

BEAM's scheduler employs a non-preemptive, work-stealing strategy, where processes voluntarily yield control after a fixed number of reductions (operations), ensuring fairness and preventing any single process from monopolizing the CPU.

The top 3

  1. BEAM's User-Space Context Switch Speed: BEAM processes achieve context switches in approximately 20 nanoseconds within user space, making them hundreds of times faster than typical OS kernel-level switches which can take 500-1000 nanoseconds (0.5-1 microsecond) due to minimal state saving.
  2. Predictable Latency via Reduction Counting: The BEAM scheduler utilizes 'reduction counts'—a unit of work (roughly a function call)—to preempt processes, ensuring no single process monopolizes the CPU and providing essential soft real-time guarantees for consistent low-latency applications.
  3. Reduction Counts: BEAM's Fairness Mechanism: To ensure fairness, the BEAM scheduler allocates a budget of reductions (e.g., 2,000 operations) to each process. Once this budget is exhausted, the process is preempted, preventing starvation and distributing CPU time equitably among concurrent processes.

Sources

Open the full topic