Skip to main content

MemoryManagement

Struct MemoryManagement 

Source
pub struct MemoryManagement<Storage> { /* private fields */ }
Expand description

Reserves and keeps track of chunks of memory in the storage, and slices upon these chunks.

Implementations§

Source§

impl<Storage: ComputeStorage> MemoryManagement<Storage>

Source

pub fn from_configuration( storage: Storage, properties: &MemoryDeviceProperties, config: MemoryConfiguration, logger: Arc<ServerLogger>, options: MemoryManagementOptions, ) -> Self

Creates the options from device limits.

Source

pub fn mode(&mut self, mode: MemoryAllocationMode)

Change the mode of allocation.

Windows nest: a Persistent or Dedicated call opens one, an Auto call closes the innermost, and the innermost open window decides the effective mode. Callers routinely nest without knowing it — a module load opens a persistent window around the whole load while the parameter machinery underneath opens one per parameter — and without the stack, the first inner window’s exit would flip the rest of the outer window back to Auto: weights landing in the dynamic pools, where every page they sit on is held for the model’s whole life.

The persistent-memory config decides what a Persistent window puts in force (Disabled and Enforced keep the configured mode); a Dedicated window is honored whatever the config, since it exists to keep a buffer out of every pool.

Source

pub fn cleanup(&mut self, cleanup: Cleanup, failures: &mut ErrorGraph)

Cleanup allocations in pools that are deemed unnecessary.

Source

pub fn get_cursor(&self, binding: ManagedMemoryBinding) -> Result<u64, IoError>

Returns the storage from the specified binding

Source

pub fn get_storage( &mut self, binding: ManagedMemoryBinding, ) -> Result<StorageHandle, IoError>

Returns the storage from the specified binding.

This is the funnel every buffer dereference passes through (get_resource delegates here), so it is where a lazily-carved allocation gets its real device backing: the handle returned always refers to mapped memory.

Source

pub fn bytes_allocated(&self) -> u64

The bytes this memory holds from the device right now, whatever pool holds them.

Source

pub fn relocation_need(&self) -> RelocationNeed

Whether emptying the outdated pools is wanted, before the bytes the device holds are known: only while something is outdated, when the arena is full or the device is short of room, and not again while the pools look as they did when the last relocation moved nothing.

Source

pub fn has_outdated(&self) -> bool

Whether a growth left pages behind for a relocation to empty.

Source

pub fn relocate( &mut self, copier: &mut dyn CopyQueue<Storage>, reason: RelocationReason, failures: &mut ErrorGraph, )

Empty what the outdated pools hold into the current pages, so the pages they held go back to the driver. reason decides whether a target may take a new page.

Source

pub fn guard(&mut self, location: MemoryLocation) -> Option<PageGuard>

Keep the page location names as it is for as long as the guard lives (see PageGuard). None when no pool holds such a page.

Source

pub fn managed_resource( &mut self, binding: ManagedMemoryBinding, offset_start: Option<u64>, offset_end: Option<u64>, ) -> Result<ManagedResource<Storage::Resource>, IoError>

The resource behind binding, holding the allocation’s binding for as long as it lives: what a caller that keeps the raw address past this call is handed. The binding keeps the allocation in place, and leaves the rest of its page to other allocations.

Source

pub fn get_resource( &mut self, binding: ManagedMemoryBinding, offset_start: Option<u64>, offset_end: Option<u64>, ) -> Result<Storage::Resource, IoError>

Returns the resource from the storage at the specified handle

Source

pub fn reserve( &mut self, size: u64, update: PageUpdate, failures: &mut ErrorGraph, ) -> Result<ManagedMemoryHandle, IoError>

Reserve size bytes, changing the pages held only as far as update allows.

§Errors

IoError::PageUpdateForbidden when update forbids a new page and the room held cannot serve it, and whatever the pools or the device refused otherwise.

Source

pub fn storage(&mut self) -> &mut Storage

Fetch the storage used by the memory manager.

§Notes

The storage should probably not be used for allocations since the handles won’t be compatible with the ones provided by the current trait. Prefer using the alloc and dealloc functions.

This is useful if you need to time the deallocations based on async computation, or to change the mode of storage for different reasons.

Source

pub fn memory_report(&self) -> MemoryPoolsReport

Everything this memory holds, pool by pool: each pool’s shape, usage and high-water marks, the dynamic ones in allocation-routing order. MemoryPoolsReport::usage sums them.

Source

pub fn print_memory_usage(&self)

Print out a report of the current memory usage.

Source

pub fn bind( &mut self, reserved: ManagedMemoryHandle, assigned: ManagedMemoryHandle, cursor: u64, failures: &mut ErrorGraph, ) -> Result<(), IoError>

Binds the given handle to a [MemorySlot].

Source

pub fn failure( &self, binding: &ManagedMemoryBinding, range: Range<u64>, ) -> Option<FailureId>

The failure claiming any byte of range in the allocation behind binding, if one does.

This is the read path’s whole check: a field on a slice the resolution walks anyway. A binding this manager does not hold answers None — lookup errors are find’s to report, and a failed lookup carries no failure to name.

Source

pub fn taint( &mut self, binding: &ManagedMemoryBinding, range: Range<u64>, failure: FailureId, failures: &mut ErrorGraph, )

Point range of the allocation behind binding at failure.

A binding this manager does not hold is left alone, for the same reason failure answers None for one.

Source

pub fn written( &mut self, binding: &ManagedMemoryBinding, range: Range<u64>, failures: &mut ErrorGraph, )

range of the allocation behind binding has a writer again: release every claim on those bytes — and only those bytes, since a partial write says nothing about the rest of the buffer.

Trait Implementations§

Source§

impl<Storage> Debug for MemoryManagement<Storage>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Storage: ComputeStorage> Display for MemoryManagement<Storage>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Storage> Freeze for MemoryManagement<Storage>
where Storage: Freeze,

§

impl<Storage> RefUnwindSafe for MemoryManagement<Storage>
where Storage: RefUnwindSafe,

§

impl<Storage> Send for MemoryManagement<Storage>
where Storage: Send,

§

impl<Storage> Sync for MemoryManagement<Storage>
where Storage: Sync,

§

impl<Storage> Unpin for MemoryManagement<Storage>
where Storage: Unpin,

§

impl<Storage> UnsafeUnpin for MemoryManagement<Storage>
where Storage: UnsafeUnpin,

§

impl<Storage> UnwindSafe for MemoryManagement<Storage>
where Storage: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more