Reduction-Based Preemption: Fairer Than Time-Slicing
BEAM's scheduler preempts processes based on 'reduction counts' – units of work performed – rather than fixed time slices, ensuring no single process hogs the CPU and providing predictable fairness for millions of lightweight processes.
The top 3
- BEAM's "Reduction" Counter: Fair Scheduling's Core: In the BEAM (Erlang/Elixir) VM, a "reduction" is an abstract unit of work, roughly equivalent to a function call or a few instructions. This counter-based preemption ensures fair scheduling by allowing processes to run for a fixed number of reductions before being preempted, preventing any single process from monopolizing the CPU, unlike time-slicing which relies on elapsed time.
- Three Core Preemption Models: Who Wins on Fairness?: Comparing scheduling fairness across models, Reduction-Based Preemption (Erlang/BEAM) offers fairness by ensuring processes get equal computational work. Time-Slicing (OS kernels like Linux) provides fairness by allocating fixed time quanta, while Cooperative Scheduling (older systems) relies on processes voluntarily yielding control, often leading to unfair resource monopolization.
- BEAM's 'Reduction' Counter: Fair Scheduling's Core: Elixir/Erlang's BEAM VM uses a 'reduction' counter, an abstract measure of work, to preempt processes after a fixed number of reductions (e.g., 2000), ensuring fair CPU time distribution regardless of operation complexity.
Sources
Open the full topic