1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! # `Method::Mmap` — memory-mapped IO with `msync` for durability
//!
//! `Method::Mmap` reads through a memory mapping and writes flow
//! through the mapping with explicit `msync(MS_SYNC)` (Linux/macOS)
//! or `FlushViewOfFile` (Windows) for durability.
//!
//! It is most useful for **read-heavy random-access** workloads,
//! where the kernel's page-cache prefetching outperforms repeated
//! `pread` syscalls. For write-heavy workloads, prefer `Direct` or
//! `Data` — `Mmap` writes still require a sync call for durability.
//!
//! `Mmap` falls back to `Sync` for files smaller than the page size,
//! special files (sockets, pipes, FIFOs), and filesystems that reject
//! `mmap`. The fallback is observable via `Handle::active_method()`.
//!
//! Run: `cargo run --example 06_method_mmap`
use ;