Skip to main content

Crate mnemosyne

Crate mnemosyne 

Source
Expand description

The Mnemosyne high-performance memory allocator global interface.

Modules§

counting
Per-thread allocation counting for allocator-budget tests.
mitigations
Compile-time security mitigation bitmask constants.
scratch
Aligned scratch pool for temporary buffers.

Macros§

aligned_vec
Constructs an AlignedVec from a literal list of elements.

Structs§

AlignedBuf
A stack-resident, fixed-capacity buffer holding up to N elements of T.
AlignedVec
A growable buffer with guaranteed byte alignment for SIMD operations.
BinSnapshot
Per-size-class allocation statistics snapshot.
BinStatsWindow
A snapshot of bin stats taken at a fixed point in time.
BrandedBlock
A wrapper representing a heap block branded with a compile-time unique lifetime.
BrandedBox
A uniquely owned, safe pointer to heap-allocated memory of type T from a Heap.
BrandedCell
A GhostCell-style shared container allowing interior mutability.
BrandedVec
A dynamically growing array allocated from a Heap.
CudaDeviceBackend
A memory backend allocating CUDA device memory.
CudaGddrBackend
A zero-sized device backend with an allocator-local GDDR pool identity.
CudaHbmBackend
A zero-sized device backend with an allocator-local HBM pool identity.
CudaHostPinnedBackend
A memory backend allocating CUDA page-locked (pinned) host memory.
CudaUnifiedBackend
A zero-copy memory backend mapping memory blocks directly using CUDA managed memory.
Drain
A draining iterator returned by AlignedVec::drain.
FastPathCacheConfig
Configuration for fast-path caches.
FastPathCacheManager
Thread-local fast-path cache manager.
FastPathEfficiencyMetrics
Snapshot of fast-path cache efficiency metrics.
HardenedPolicy
Zero-Sized Type (ZST) representing a hardened allocation policy with memory poisoning, zero-initialization, and free-list XOR encryption.
Heap
A scoped, lifetime-branded memory heap.
IntoIter
Consuming iterator that moves elements out of an AlignedVec<T>.
MemoryBackendWrapper
High-level OS page mapping backend helper. Owns the wrapper struct shape and forwards the platform-conditional capability consts from crate::DefaultBackend; per-method bodies delegate to per-concern helpers in crate::guard and crate::reset.
MemoryStats
Snapshot of Mnemosyne memory mapping and segment cache state.
Mnemosyne
The Mnemosyne global allocator structure.
MnemosyneAllocator
Generic global allocator that is parameterized by an allocation policy P and a memory backend B.
MnemosyneOptions
Runtime configuration options for the Mnemosyne allocator.
PolicyMarker
Zero-sized type (ZST) that brands a data structure with the allocator policy used to create it — zero runtime cost (PhantomData<P>).
ReallocError
A failed branded reallocation that retains ownership of the source block.
ScratchBank
A fixed set of same-typed scratch pools for domain-specific temporary roles.
ScratchPool
A pool of reusable, aligned scratch buffers for a specific element type.
SecurePolicy
Zero-Sized Type (ZST) representing a secure allocation policy with memory poisoning and zero-initialization.
SizeClassCache
Per-size-class cache for frequently-used allocation sizes.
SizeClassInfo
Bundles all the per-class constants that are computed separately in the individual lookup functions — convenient when a consumer needs multiple fields for the same class without repeated calls.
SizeClassOccupancy
Occupancy counters for a single size class in the current thread allocator.
StandardPolicy
Zero-Sized Type (ZST) representing the standard allocation policy with maximum performance.
SyncRegionToken
A brand owner that is Send + Sync and may be handed across thread boundaries to relocate exclusive write capability.
ThreadLocalToken
A brand owner that is statically pinned to one thread.

Enums§

ReallocFailure
The reason a branded reallocation could not produce a replacement block.

Constants§

DEFAULT_SCRATCH_ALIGN
Default alignment for scratch buffers (64 bytes = one AVX-512 cache line).
LEMIRE_DIV_SHIFT
Shift constant for the Lemire indirect reciprocal.
MAX_POOL_SLOTS
Maximum concurrent borrows (recursive/nested calls) the pool supports.
NUM_SIZE_CLASSES
The total number of small size classes.

Traits§

AllocPolicy
A sealed trait representing an allocator behavior and safety policy.
LocalAllocatorSelector
Backend hook that supplies the thread-local allocator cache and mode-keyed selector entry points for a concrete segment pool backend. The backend-local thread allocator selection API.
ScratchElement
Element types that the scratch pool can manage.

Functions§

all_bin_snapshots
Returns snapshots for all NUM_SIZE_CLASSES size classes.
all_class_info
Returns an iterator-compatible array of SizeClassInfo for all classes.
alloc_distribution
Returns the fractional distribution of alloc_count across all size classes as an array of f64 values in [0.0, 1.0] that sum to 1.0.
bin_snapshot
Returns a snapshot for size class class, or None if out of range.
block_index_in_page
Block index within a page using Lemire reciprocal multiplication.
branded_scope
Executes a closure with a fresh, compile-time unique branded heap and token.
class_to_max_blocks
Maps a size class index to its maximum number of blocks in a page.
class_to_size
Maps a size class index to its maximum block size.
configure
Configures the allocator runtime settings programmatically.
decay
Triggers a manual background decay and defragmentation cycle across all active memory backends.
disable_leak_detector
Disables the built-in memory leak detector.
disable_profiling
Disables the built-in Poisson heap sampler.
dump_leaks
Dumps all active allocations (representing leaks) with their resolved stacks to a file.
dump_profile
Dumps a folded stack profile of active memory allocations to a file.
enable_leak_detector
Enables the built-in memory leak detector, tracking every allocation with its backtrace.
enable_profiling
Enables the built-in Poisson heap sampler.
flush_tls_stats
Flushes the calling thread’s pending bin-stats batch to the global counters.
get_options
Returns the current allocator configuration options snapshot.
hottest_class
Returns the index of the hottest size class (highest alloc_count), or None when nothing has ever been allocated.
is_cuda_available
Returns true if the CUDA unified memory driver was successfully resolved.
is_leak_detector_enabled
Returns whether the memory leak detector is currently active.
is_profiling_enabled
Returns whether the built-in heap sampler is currently active.
memory_stats
Returns current Mnemosyne allocator memory counters for the default Mnemosyne allocator.
memory_stats_generic
Returns current Mnemosyne allocator memory counters for a specific policy and backend.
memory_stats_json
Returns a JSON representation of the current memory statistics and per-size-bin counters as an owned String.
policy_summary
Returns a human-readable one-line summary of the current policy and telemetry.
purge
Purges the global segment pool, releasing all retained/cached segments back to the OS.
purge_generic
Purges the global segment pool for a specific backend, releasing all retained/cached segments back to the OS.
purge_lazy
Purges the global segment pool while keeping warm_threshold committed segments ready for immediate reuse.
purge_standard
Purges with StandardPolicy::SEGMENT_POOL_WARM_THRESHOLD warm segments kept.
register_alloc_hook
Registers a custom user allocation tracing hook.
register_free_hook
Registers a custom user deallocation tracing hook.
reset
Asks the OS to drop the physical backing of every retained standard free segment without removing them from the cache.
reset_bin_stats
Resets all per-class counters to zero.
reset_generation_count
Returns the current value of the reset generation counter.
reset_generic
Asks the OS to drop the physical backing of every retained standard free segment for a specific backend without removing them from the cache.
round_up_size_saturating
Returns the class stride for the given request, saturating to the largest class when size > MAX_SMALL_ALLOC_SIZE.
size_class_fragmentation
Returns the internal fragmentation for a request of size bytes: (class_stride - size) / class_stride, in [0.0, 1.0].
size_to_class
Maps an allocation size to its corresponding size class index.
size_to_class_nonzero
Maps a non-zero allocation size to its corresponding size class index.
summary_line
One-line human-readable summary of process-wide bin stats.
sync_scope
Executes a closure with a fresh, thread-portable branded heap and token.
top_n_classes
Returns the n hottest size classes by alloc_count, sorted descending.
total_alloc_count
Process-wide total allocation count across all small size classes.
total_internal_fragmentation
Process-wide internal fragmentation ratio: (total_alloc_bytes - total_requested_bytes) / total_alloc_bytes.
total_live_bytes
Process-wide live bytes in the small allocator: sum of live_estimate × block_size across all classes.
total_requested_bytes
Process-wide cumulative user-requested bytes across all small size classes.
usable_size⚠
Returns the actual usable byte count of the allocation at ptr.
warm_current_thread
Forces the Mnemosyne thread-local allocator to initialize for the current thread by performing a minimal allocation and deallocation through the Mnemosyne allocator.

Type Aliases§

InvariantLifetime
A zero-sized marker that is invariant in 'brand and unconditionally Send + Sync.