bash tasks are the OOM killer's first victims: score 1000, subagent runs 900, MemoryHigh on the bash daemon
This commit is contained in:
parent
d4dc8b48b1
commit
77f33a23d8
1 changed files with 155 additions and 32 deletions
|
|
@ -2105,10 +2105,10 @@ fn acp_session_file(sessions: &Path, name: &str) -> PathBuf {
|
|||
sessions.join(format!("subagent-acp-session-{name}"))
|
||||
}
|
||||
|
||||
/// A subagent run's `oom_score_adj`: the maximum, so under memory pressure
|
||||
/// the kernel takes a subagent run before a bash task (0) or the agent's
|
||||
/// own session (-500, `nix/agent-modules/agent-service.nix`).
|
||||
const RUN_OOM_SCORE_ADJ: i32 = 1000;
|
||||
/// A subagent run's `oom_score_adj`: under memory pressure the kernel takes a
|
||||
/// bash task (1000) first, then a subagent run, then the agent's own session
|
||||
/// (-500, `nix/agent-modules/agent-service.nix`).
|
||||
const RUN_OOM_SCORE_ADJ: i32 = run_cgroup::SUBAGENT_RUN_OOM_SCORE_ADJ;
|
||||
|
||||
/// The ACP runtime `name`'s run drives, keeping its session id in
|
||||
/// [`acp_session_file`] and answering permission requests per
|
||||
|
|
@ -2730,6 +2730,12 @@ fn turn_end_summary(name: &str, end: &TurnEnd, stop: Option<&StopReason>) -> Str
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_subagent_run_is_killed_after_a_bash_task_and_before_the_session() {
|
||||
assert_eq!(RUN_OOM_SCORE_ADJ, 900);
|
||||
assert!(RUN_OOM_SCORE_ADJ < run_cgroup::BASH_TASK_OOM_SCORE_ADJ);
|
||||
}
|
||||
|
||||
// `Cancel` can only be constructed from a real spawned process (no test
|
||||
// fixture in `hive_claude` for it), so these exercise the reservation
|
||||
// half of `State` directly — the actual TOCTOU-closure logic — rather
|
||||
|
|
|
|||
Loading…
Reference in a new issue