Concurrent-aware, prioritized, madvise on *-nix

I’ve recently released olio 0.4.0 with a new feature that is novel, at least in my evolution as a rust programmer. These published benchmarks show a significant performance advantage to zero-copy mapped sequential access with pre-use of advise(Sequential). From the olio CHANGELOG:

  • New mem::MemHandle wrapper for Mmap or other Deref byte buffer types, offering concurrent-aware access advice. This is currently limited to *nix libc::posix_madvise with a subset of advice flags, and is no-op on other platforms.

May I please request a moment of your time for a code review or other form of constructive criticism on the design, which is summarized:

               /------- advice: Cell<(enum i32) MemAdvice>
MemHandle<Mmap>  (1) ---(Arc)--> (priv) Mem<Mmap> --> (owned) Mmap
[...]             ⁝             /        \-----------> advisors: AtomicUsize 
MemHandle<Mmap>  (n) ---(Arc)--/

The AtomicUsize has bit packed advisors counts, currently for advice levels Random and Sequential. Normal is default. The highest priority surviving handle advice wins (is sent to kernel). The structure has expansion room for WillNeed, which I think is also more portable. The use of the Cell makes the MemHandle !Sync but its still inexpensive Clone and Send.

Also I would love some help (PR) to make all or part of this work at parity on windows. Currently it is a no-op.

Thanks for your consideration.

1 Like

Post release, added a better fully threaded/randomized unit test which may be helpful if anyone is missing the the purpose of this, or concerned about my initial not-so-great test coverage.

Any comment, even small?