mnemosyne-backend 0.6.0

Memory backend contracts for the Mnemosyne allocator
Documentation
  • Coverage
  • 100%
    32 out of 32 items documented0 out of 2 items with examples
  • Size
  • Source code size: 136.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 677.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ryancinsight/Mnemosyne
    1 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ryancinsight

mnemosyne-backend

Memory backend implementations for the Mnemosyne allocator: the layer that turns MemoryBackend calls into OS virtual-memory operations.

[dependencies]
mnemosyne-backend = "0.5"

Layout, by concern

  • mapping — the MemoryBackendWrapper struct and the single central impl MemoryBackend for MemoryBackendWrapper block (trait coherence requires one file). allocate and deallocate live inline; make_guard, page_reset, and decommit delegate to the helpers below via #[inline(always)] static dispatch.
  • guard — PROT_NONE (mprotect) / PAGE_NOACCESS (VirtualProtect) guard installation, used for segment-tail out-of-bounds trapping.
  • reset — page_reset (MADV_DONTNEED on Linux, MADV_FREE on macOS/FreeBSD, MEM_RESET on Windows) and decommit. These drop physical backing while keeping the virtual mapping committed.
  • recorders — telemetry counter statics and the BackendMemoryStats snapshot, reachable publicly through backend_memory_stats().
  • backends — UnixBackend, WindowsBackend, the CUDA backends (CudaUnifiedBackend, CudaDeviceBackend, tier-keyed CudaHbmBackend and CudaGddrBackend, CudaHostPinnedBackend), and DefaultBackend, which selects the OS-conditional backing at compile time.

Release accounting

MemoryBackend::deallocate returns a release-success boolean and is #[must_use]. current_mapped_bytes is decremented only on confirmed OS release; a failed munmap/VirtualFree routes through record_unmap_failure so the counter cannot under-count still-mapped bytes. page_reset and make_guard never decrement it — the mapping stays owned, only the resident set drops.

On Linux, segment-sized mappings receive a madvise(MADV_HUGEPAGE) hint. The hint is advisory; failure never invalidates the mapping.

Licensed under MIT OR Apache-2.0.