BEAM's 'Reduction' Unit for Fair Scheduling

The BEAM scheduler uses 'reductions' as its internal unit of work, where each reduction represents an operation like a function call or message passing. Each Erlang process is allotted a fixed number of reductions (typically 2000-4000) before being preempted, ensuring fair CPU distribution independent of OS timers.

The top 3

  1. BEAM's 'Reduction' Unit: What It Counts: In Erlang's BEAM VM, a 'reduction' is a fundamental unit of work, roughly equivalent to a function call, arithmetic operation, or message passing. The scheduler tracks these reductions, typically preempting a process after a budget of 2000 reductions to ensure fair CPU allocation.
  2. Reductions vs. OS Time Slices: The Portability Edge: BEAM uses reductions for preemptive scheduling instead of traditional OS time slices primarily for performance and portability. Counting reductions (integer decrements) is more efficient and consistent across different operating systems than relying on expensive, variable OS-level time readings.
  3. Fairness Guarantee: Preventing CPU Starvation: The reduction-based preemptive scheduler ensures no single process can monopolize the CPU, even if stuck in an infinite loop. By limiting a process's reductions before preemption, BEAM guarantees predictable response times and soft real-time behavior, preventing other processes from starving for CPU time.

Sources

Open the full topic