Skip to content

Commit 8df00f0

Browse files
Michael Liufacebook-github-bot
authored andcommitted
prevent below process being evicted out of memory
Summary: As an effort to reduce latency. We will mlock the record process to avoid any potential page fault. Reviewed By: lnyng Differential Revision: D73802160 fbshipit-source-id: 8f9cfcf5c80582237db14ac22cf67a46f3085aea
1 parent d76d028 commit 8df00f0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

below/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ use clap_complete::Shell;
4444
use clap_complete::generate;
4545
use cursive::Cursive;
4646
use indicatif::ProgressBar;
47+
use nix::sys::mman::MlockAllFlags;
48+
use nix::sys::mman::mlockall;
4749
use regex::Regex;
4850
use signal_hook::iterator::Signals;
4951
use slog::debug;
@@ -1034,6 +1036,15 @@ fn record(
10341036
},
10351037
);
10361038

1039+
let ret = mlockall(MlockAllFlags::MCL_CURRENT);
1040+
if ret.is_err() {
1041+
warn!(
1042+
logger,
1043+
"mlockall failed: {}. Continue without mlock",
1044+
std::io::Error::last_os_error()
1045+
);
1046+
}
1047+
10371048
loop {
10381049
if !disable_exitstats {
10391050
// Anything that comes over the error channel is an error

0 commit comments

Comments
 (0)