forked from filecoin-project/curio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ffiselect: Set /proc/pid/oom_score_adj=900 for non-PoSt tasks (fileco…
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use crate::utils::oom::set_oom_score_adj; | ||
|
||
pub fn spawn_task(task: Task) -> Result<Child, Error> { | ||
let child = Command::new(task.program) | ||
.args(&task.args) | ||
// ... other command setup ... | ||
.spawn()?; | ||
|
||
// Set high OOM score for non-PoSt tasks | ||
if !task.is_post_task() { | ||
if let Err(e) = set_oom_score_adj(child.id() as i32, 900) { | ||
log::warn!("Failed to set OOM score adjustment: {}", e); | ||
// Continue execution even if setting OOM score fails | ||
} | ||
} | ||
|
||
Ok(child) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use std::fs; | ||
use std::io; | ||
use std::path::Path; | ||
|
||
pub fn set_oom_score_adj(pid: i32, score: i16) -> io::Result<()> { | ||
let path = format!("/proc/{}/oom_score_adj", pid); | ||
fs::write(Path::new(&path), score.to_string()) | ||
} |