MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / utilization_percent

Method utilization_percent

nodedb-mem/src/budget.rs:192–199  ·  view source on GitHub ↗

Utilization as a percentage (0-100). Computed in `u128` so a corrupted (e.g. underflow-wrapped near `usize::MAX`) `allocated` clamps to 100 % rather than panicking on `allocated * 100` overflow — a panic here is taken inside the Data Plane core loop (`apply_spsc_pressure` → `snapshot`) and escalates to a DEGRADED core.

(&self)

Source from the content-addressed store, hash-verified

190 /// Plane core loop (`apply_spsc_pressure` → `snapshot`) and escalates
191 /// to a DEGRADED core.
192 pub fn utilization_percent(&self) -> u8 {
193 let limit = self.limit();
194 if limit == 0 {
195 return 100;
196 }
197 let allocated = self.allocated() as u128;
198 ((allocated * 100) / limit as u128).min(100) as u8
199 }
200
201 /// Peak allocation (high-water mark).
202 pub fn peak(&self) -> usize {

Callers 3

engine_pressureMethod · 0.80
worst_engine_pressureMethod · 0.80
snapshotMethod · 0.80

Calls 2

allocatedMethod · 0.80
limitMethod · 0.45

Tested by

no test coverage detected