Validate that every fraction is positive and finite and that they sum to no more than the whole. Every engine must get a strictly-positive budget: a zero budget is reported by the governor as 100% utilization → Emergency pressure, which rejects writes to that engine with `resources exhausted`.
(&self)
| 115 | /// reported by the governor as 100% utilization → Emergency pressure, |
| 116 | /// which rejects writes to that engine with `resources exhausted`. |
| 117 | pub fn validate(&self) -> crate::Result<()> { |
| 118 | for &engine in EngineId::ALL { |
| 119 | let f = self.fraction_for(engine); |
| 120 | if !f.is_finite() || f <= 0.0 { |
| 121 | return Err(crate::Error::Config { |
| 122 | detail: format!( |
| 123 | "engine budget fraction for {engine} must be a positive finite \ |
| 124 | number, got {f}" |
| 125 | ), |
| 126 | }); |
| 127 | } |
| 128 | } |
| 129 | let total = self.total_fraction(); |
| 130 | if total > 1.0 { |
| 131 | return Err(crate::Error::Config { |
| 132 | detail: format!("engine budget fractions sum to {total:.3}, must be <= 1.0"), |
| 133 | }); |
| 134 | } |
| 135 | Ok(()) |
| 136 | } |
| 137 | |
| 138 | /// Convert fractions to absolute byte budgets for every `EngineId`, |
| 139 | /// given the global memory limit. |