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
|
|
@ -19,12 +19,15 @@
|
|||
# it in login shells that no unit starts (`nixos-container root-login`).
|
||||
# `hive-agent` and `hive-subagent-daemon` spawn `claude` as a plain child,
|
||||
# which inherits it, so neither unit may set or unset it.
|
||||
# - `MemoryHigh=` on `hive-subagent-daemon`, two thirds of the cap, as a
|
||||
# generator drop-in. The daemon spawns nested `claude` sessions as plain
|
||||
# children, so its cgroup already is the "all subagents" cgroup. `High`, not
|
||||
# `Max`: past it the kernel reclaims hard and the subagents slow down, so the
|
||||
# last third stays free for the agent's own turn, but a subagent that needs
|
||||
# more still gets it when the container has memory to spare.
|
||||
# - `MemoryHigh=` on `hive-subagent-daemon` and on `hive-bash-daemon`, two
|
||||
# thirds of the cap each, as generator drop-ins. The subagent daemon spawns
|
||||
# nested `claude` sessions as plain children, so its cgroup already is the
|
||||
# "all subagents" cgroup. The bash daemon's cgroup holds every bash task
|
||||
# (`tasks/<id>/`), so a `cargo` or `nix build` storm throttles itself there
|
||||
# before it reaches the container's `MemoryMax=`. `High`, not `Max`: past it
|
||||
# the kernel reclaims hard and the work slows down, so the last third stays
|
||||
# free for the agent's own turn, but a task that needs more still gets it when
|
||||
# the container has memory to spare.
|
||||
#
|
||||
# Tested by `checks.script-test-agent-memory-cap` and
|
||||
# `checks.module-eval-agent-memory`.
|
||||
|
|
@ -52,9 +55,11 @@ let
|
|||
# with the unit's own file in /etc.
|
||||
unitGenerator = pkgs.writeShellScript "hyperhive-memory-cap" ''
|
||||
${readCap "exit 0"}
|
||||
dir="$1/hive-subagent-daemon.service.d"
|
||||
${pkgs.coreutils}/bin/mkdir -p "$dir"
|
||||
printf '[Service]\nMemoryHigh=%s\n' "$((bytes * 2 / 3))" > "$dir/50-memory-high.conf"
|
||||
for unit in hive-subagent-daemon hive-bash-daemon; do
|
||||
dir="$1/$unit.service.d"
|
||||
${pkgs.coreutils}/bin/mkdir -p "$dir"
|
||||
printf '[Service]\nMemoryHigh=%s\n' "$((bytes * 2 / 3))" > "$dir/50-memory-high.conf"
|
||||
done
|
||||
'';
|
||||
|
||||
# The generators run before the container's journal starts and an nspawn
|
||||
|
|
@ -67,7 +72,7 @@ let
|
|||
else
|
||||
why="is missing"
|
||||
fi
|
||||
echo "<4>/run/hive/memory-max-bytes $why: no BUN_JSC_forceRAMSize heap ceiling and no MemoryHigh= on hive-subagent-daemon; the host's MemoryMax= on the container still applies." >&2
|
||||
echo "<4>/run/hive/memory-max-bytes $why: no BUN_JSC_forceRAMSize heap ceiling and no MemoryHigh= on hive-subagent-daemon or hive-bash-daemon; the host's MemoryMax= on the container still applies." >&2
|
||||
exit 0
|
||||
''}
|
||||
'';
|
||||
|
|
|
|||
Loading…
Reference in a new issue