pub struct Budget { /* private fields */ }Expand description
A memory budget for a single engine.
Tracks current allocation against a configurable limit using atomic counters (safe to read from any thread — metrics exporter, governor, etc.).
The allocated counter is stored behind an Arc so that
ReservationToken can hold a
reference to it without requiring a back-reference to the governor.
Implementations§
Source§impl Budget
impl Budget
Sourcepub fn try_reserve(&self, size: usize) -> bool
pub fn try_reserve(&self, size: usize) -> bool
Try to reserve size bytes from this budget.
Returns true if the reservation succeeded, false if it would
exceed the limit.
Sourcepub fn try_reserve_arc(&self, size: usize) -> Option<Arc<AtomicUsize>>
pub fn try_reserve_arc(&self, size: usize) -> Option<Arc<AtomicUsize>>
Try to reserve size bytes and return a shared Arc to the allocated
counter so the caller can decrement it on drop.
Returns Some(arc) on success, None on budget exhaustion.
Sourcepub fn release(&self, size: usize)
pub fn release(&self, size: usize)
Release size bytes back to the budget.
Saturates to zero if size exceeds the current allocation (which can
happen when data is replayed from WAL without a matching reservation).
Sourcepub fn over_release_count(&self) -> usize
pub fn over_release_count(&self) -> usize
Number of over-release events observed on this budget. A
non-zero value is the smoking-gun signal that some call-site
is releasing more bytes than it reserved. Per-engine
allocated() saturates to zero on over-release, so this
counter is the only post-hoc observable.
Sourcepub fn utilization_percent(&self) -> u8
pub fn utilization_percent(&self) -> u8
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.
Sourcepub fn rejections(&self) -> usize
pub fn rejections(&self) -> usize
Number of rejected allocation attempts.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.