Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Prohibit swapping, or at least count/measure swaps?
Would like to ensure a program never swaps, and only uses RAM and CPU caches. Running on Linux.
I am not an expert at this level of computing, but am trying to learn.
Looking at libc
, would mlockall(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT)
be the correct approach?
If so, would it still be possible that some shared library would be swapped before execution begins in fn main()
(I assume the earliest mlockall
could be called would be the top of main...) but at least the MCL_ONFAULT would lock it the next time it got read?
(Ideally, the requirement not to swap would apply only to initialized memory, not to all allocated memory, since when data structures reallocate and double in size for the last time during an execution it's likely that much of the recently-allocated memory will never be "used"--written to or read from--by the program. But this feels like too much to ask on top of what already seems to be a thorny requirement.)
(If impossible to ensure no swapping, then would like to count/measure swaps to know whether it happened or not/how much, but perhaps this is harder with libc's RUSAGE ru_nswap being unmaintained on Linux.)
(
Follow up question would be, once the memory usage is constrained to RAM and caches, how to correctly limit it -- libc's setrlimt with which of the following?
)
2 posts - 2 participants
🏷️ rust_feed