mod scaling

module scaling

Successive-halving population control for a live coordinator roster. Successive-halving population control for a live coordinator roster.

Rungs are (r_0 eta^i). Replicas that have charged at least the current rung are ranked by best energy; the bottom (1 - 1/eta) are retired and the same number of spawns is requested. A manual target emits the retire or spawn decisions that reach that live count.

Enums

enum ScaleDecision

One decision emitted by SuccessiveHalving.

Retire(u32)

Remove this replica from the live roster.

Spawn(u32)

Request this many new workers.

enum ScalingError

Invalid successive-halving parameters.

InvalidR0(u64)

The first rung must be a positive charged-work count.

InvalidEta(f64)

The reduction factor must be finite and strictly greater than one.

InvalidTarget

The population target must be at least one replica.

Structs and Unions

struct SuccessiveHalving

Resource-rung successive halving over live replicas.

Implementations

impl SuccessiveHalving

Functions

fn new(r0: u64, eta: f64, population_target: u32) -> Result<Self, ScalingError>

Construct a policy with first rung r0, reduction eta, and a cohort size that must cross a rung before it is scored.

fn observe(&mut self, replica: u32, charged_work: u64, best_energy: f64) -> Vec<ScaleDecision>

Record one replica’s charged work and best energy, emitting retire and spawn decisions for every newly completed rung.

fn rung(&self, index: u32) -> Option<u64>

Charged-work threshold of rung index, (r_0 eta^{mathrm{index}}).

fn set_target(&mut self, live: u32) -> Vec<ScaleDecision>

Emit retires or a spawn so the live set reaches live.