fit_decode_ring_slots

Function fit_decode_ring_slots 

Source
pub fn fit_decode_ring_slots(
    start_slots: usize,
    reserve_without_ring: usize,
    bytes_per_ring_slot: usize,
    free_mem: usize,
) -> usize
Expand description

Largest DECODE_RING_FIT_LADDER depth <= start_slots whose ring term still fits in free_mem alongside everything else the reserve needs (#915). Pure — preflight owns the bytes, this owns the ladder.

bytes_per_ring_slot is ONE depth unit: max_batch_size × the per-seq SSM state blob, the same product ssm_snapshot_bytes multiplies the depth by.

Returns 0 when nothing fits — including the case where the rest of the reserve ALONE exceeds free_mem, which is the caller’s cue to refuse with the existing suggested-batch text rather than to boot a ringless serve.