pub struct ResourceAccountant { /* private fields */ }Expand description
Low-overhead single-owner framework resource ownership accountant.
Implementations§
Source§impl ResourceAccountant
Single-owner registration, fence-deferred release, owner destruction, and leak attribution for ResourceAccountant.
impl ResourceAccountant
Single-owner registration, fence-deferred release, owner destruction, and leak attribution for ResourceAccountant.
Sourcepub fn register_resource(
&mut self,
owner: ResourceOwnerId,
kind: TrackedResourceKind,
handle_id: u64,
byte_size: usize,
retention: ResourceRetentionClass,
)
pub fn register_resource( &mut self, owner: ResourceOwnerId, kind: TrackedResourceKind, handle_id: u64, byte_size: usize, retention: ResourceRetentionClass, )
Registers or updates a tracked resource under a single authoritative owner, deduplicating by (kind, handle_id).
§Arguments
&Self- Mutable resource accountant.ResourceOwnerId- Single authoritative resource owner.TrackedResourceKind- Resource category.u64- Unique resource handle identifier withinkind.usize- Estimated byte footprint.ResourceRetentionClass- Initial retention classification.
Sourcepub fn update_retention(
&mut self,
kind: TrackedResourceKind,
handle_id: u64,
retention: ResourceRetentionClass,
retire_fence_id: u64,
) -> bool
pub fn update_retention( &mut self, kind: TrackedResourceKind, handle_id: u64, retention: ResourceRetentionClass, retire_fence_id: u64, ) -> bool
Updates the retention classification and optional GPU retirement fence of an already-tracked resource.
§Arguments
&Self- Mutable resource accountant.TrackedResourceKind- Resource category.u64- Resource handle identifier.ResourceRetentionClass- Replacement retention class.u64- GPU fence required before release (0when immediate).
§Returns
bool-trueif the resource was found and updated.
Sourcepub fn release_resource(
&mut self,
kind: TrackedResourceKind,
handle_id: u64,
) -> bool
pub fn release_resource( &mut self, kind: TrackedResourceKind, handle_id: u64, ) -> bool
Sourcepub fn mark_owner_destroyed(
&mut self,
owner: ResourceOwnerId,
now_ms: u64,
retire_fence_id: u64,
) -> usize
pub fn mark_owner_destroyed( &mut self, owner: ResourceOwnerId, now_ms: u64, retire_fence_id: u64, ) -> usize
Releases all non-GPU resources belonging to owner and transitions GPU resources awaiting retire_fence_id to PendingFenceRelease.
§Arguments
&Self- Mutable resource accountant.ResourceOwnerId- Destroyed owner identifier.u64- Monotonic destruction timestamp in milliseconds.u64- GPU retirement fence identifier (0if no GPU work references this owner).
§Returns
usize- Number of resources still remaining live underownerafter marking destruction.
Sourcepub fn complete_gpu_fence(&mut self, fence_id: u64) -> usize
pub fn complete_gpu_fence(&mut self, fence_id: u64) -> usize
Sourcepub fn set_page_counts(
&mut self,
active: usize,
frozen: usize,
evicted: usize,
destroyed: u64,
)
pub fn set_page_counts( &mut self, active: usize, frozen: usize, evicted: usize, destroyed: u64, )
Updates the high-level page lifecycle phase counters reported in snapshots.
§Arguments
&Self- Mutable resource accountant.usize- Active page count.usize- Frozen page count.usize- Evicted cold page snapshot count.u64- Cumulative destroyed page count.
Sourcepub fn snapshot(
&self,
now_ms: u64,
grace_period_ms: u64,
) -> ResourceAccountingSnapshot
pub fn snapshot( &self, now_ms: u64, grace_period_ms: u64, ) -> ResourceAccountingSnapshot
Captures a structured ResourceAccountingSnapshot cleanly separating expected_retained from destroyed_owner.live_objects.
§Arguments
&Self- Resource accountant reference.u64- Current monotonic timestamp in milliseconds.u64- Grace period in milliseconds after owner destruction before classifying remaining live objects as leaks.
§Returns
ResourceAccountingSnapshot- Complete ownership and leak-attribution telemetry snapshot.
Source§impl ResourceAccountant
impl ResourceAccountant
pub fn get_completed_gpu_fence_id(&self) -> u64
pub fn get_pages_active(&self) -> usize
pub fn get_mut_pages_active(&mut self) -> &mut usize
pub fn set_pages_active(&mut self, val: usize) -> &mut Self
pub fn get_pages_frozen(&self) -> usize
pub fn get_mut_pages_frozen(&mut self) -> &mut usize
pub fn set_pages_frozen(&mut self, val: usize) -> &mut Self
pub fn get_pages_evicted(&self) -> usize
pub fn get_mut_pages_evicted(&mut self) -> &mut usize
pub fn set_pages_evicted(&mut self, val: usize) -> &mut Self
pub fn get_pages_destroyed(&self) -> u64
pub fn get_mut_pages_destroyed(&mut self) -> &mut u64
pub fn set_pages_destroyed(&mut self, val: u64) -> &mut Self
pub fn get_total_registrations(&self) -> u64
pub fn get_total_releases(&self) -> u64
Trait Implementations§
Source§impl Clone for ResourceAccountant
impl Clone for ResourceAccountant
Source§impl Debug for ResourceAccountant
impl Debug for ResourceAccountant
Auto Trait Implementations§
impl Forget for ResourceAccountant
impl Freeze for ResourceAccountantwhere
*const u8 is !null: Freeze,
PhantomData<((TrackedResourceKind, u64), TrackedResourceRecord)>: Freeze,
PhantomData<(ResourceOwnerId, (u64, u64))>: Freeze,
impl Move for ResourceAccountant
impl RefUnwindSafe for ResourceAccountant
impl Send for ResourceAccountantwhere
RawTable<((TrackedResourceKind, u64), TrackedResourceRecord)>: Send,
RawTable<(ResourceOwnerId, (u64, u64))>: Send,
impl Sync for ResourceAccountantwhere
RawTable<((TrackedResourceKind, u64), TrackedResourceRecord)>: Sync,
RawTable<(ResourceOwnerId, (u64, u64))>: Sync,
impl Unpin for ResourceAccountant
impl UnsafeUnpin for ResourceAccountantwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<((TrackedResourceKind, u64), TrackedResourceRecord)>: UnsafeUnpin,
PhantomData<(ResourceOwnerId, (u64, u64))>: UnsafeUnpin,
impl UnwindSafe for ResourceAccountantwhere
HashMap<(TrackedResourceKind, u64), TrackedResourceRecord>: UnwindSafe,
HashMap<ResourceOwnerId, (u64, u64)>: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more