• Stefy Lanza (nextime / spora )'s avatar
    oom: the server should be the last thing the kernel kills, not the first · 860b3dd1
    Stefy Lanza (nextime / spora ) authored
    When zeiss ran out of memory this morning the OOM killer picked coderai-nvidia.
    Not because it was at fault — a runaway test process was — but because oom_score
    is essentially "how much memory does this task hold", and an engine with a model
    loaded is always near the top of that list. The leak carried on; the thing that
    was serving died; the box needed a hard reset.
    
    Linux offers one lever, /proc/<pid>/oom_score_adj, and two rules that decide
    where it can be pulled from. Both were verified on the two production hosts
    rather than assumed:
    
      raising is free, lowering needs CAP_SYS_RESOURCE — and a docker container does
      not have it (tested: in-container `echo -500` is denied, `echo 200` succeeds).
      So the protected base has to come from the engine daemon, via
      --oom-score-adj on the run, and everything inside can only step back UP from it.
    
      rootless podman cannot protect at all: a negative value is clamped to 0. 0 is
      still worth having on the Digesta host, where coderai currently sits at +200 —
      inherited from systemd's user manager, which makes it a PREFERRED victim with a
      kernel score of 800 against zeiss's 670.
    
    So: the container gets -500 (CODERAI_OOM_SCORE_ADJ, 0 disables), and inside it
    codai/util/oom.py states the order as three tiers relative to that base —
    engines +100, workers +300, training +500. Relative, because the base differs by
    host and a tier should keep its distance whatever it turns out to be. Engines are
    marked in the existing _engine_preexec hook, which covers the isolated model
    workers too: they are spawned by the engine, not the front, so they inherit it.
    Training is marked from the parent after Popen — a preexec_fn would run Python
    between fork and exec in a threaded server, which is the documented way to
    deadlock.
    
    The ordering is the point. Protecting everything equally would just move the
    bullet to an innocent bystander; this way the kernel sheds a training run (hours,
    restartable) before an engine (loses its in-flight work, and the front notices
    and respawns it) before the front (loses everything, including the ability to
    respawn anything).
    
    Every helper can only ever make a process MORE killable: nudge() refuses a
    negative delta rather than attempting a privileged write, because a process that
    believes it is protected and is not is worse than one that knows it is exposed.
    All of it is best-effort — a process that cannot adjust its score still serves.
    
    16 tests, including that the number reaches the kernel and moves the score, that
    a child can be marked from the parent, and that the engine mark sits inside a try
    (it runs between fork and exec, so anything that raises there fails the spawn).
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_019sRvvg5WSdLgcFUM96pmE4
    860b3dd1
Name
Last commit
Last update
..
__init__.py Loading commit data...
_film_net.py Loading commit data...
_rife_ifnet.py Loading commit data...
app.py Loading commit data...
archive.py Loading commit data...
audio_backends.py Loading commit data...
audio_clean.py Loading commit data...
audio_gen.py Loading commit data...
audio_stems.py Loading commit data...
audiocraft_worker.py Loading commit data...
canary_worker.py Loading commit data...
characters.py Loading commit data...
colibri_worker.py Loading commit data...
compose.py Loading commit data...
crisperwhisper_worker.py Loading commit data...
custom_pipelines.py Loading commit data...
diarization.py Loading commit data...
ds4_kv_janitor.py Loading commit data...
ds4_worker.py Loading commit data...
embeddings.py Loading commit data...
environments.py Loading commit data...
faceswap.py Loading commit data...
fastlog.py Loading commit data...
h3_worker.py Loading commit data...
host_worker.py Loading commit data...
hub_compat.py Loading commit data...
images.py Loading commit data...
k3_worker.py Loading commit data...
kt_worker.py Loading commit data...
lipsync.py Loading commit data...
log.py Loading commit data...
longcat_worker.py Loading commit data...
lora_archs.py Loading commit data...
loras.py Loading commit data...
melotts_worker.py Loading commit data...
model_test.py Loading commit data...
models_transfer.py Loading commit data...
mux_remote.py Loading commit data...
ocr.py Loading commit data...
parler_worker.py Loading commit data...
pipelines.py Loading commit data...
pod_http.py Loading commit data...
pod_tls.py Loading commit data...
prompt_cache.py Loading commit data...
pyannote_worker.py Loading commit data...
ratelimit.py Loading commit data...
remote_gateway.py Loading commit data...
rerank.py Loading commit data...
runpod_client.py Loading commit data...
runpod_ledger.py Loading commit data...
runpod_worker.py Loading commit data...
spatial.py Loading commit data...
speaker_embeddings.py Loading commit data...
speaker_registry.py Loading commit data...
state.py Loading commit data...
stt_backends.py Loading commit data...
text.py Loading commit data...
transcriptions.py Loading commit data...
tts.py Loading commit data...
tts_backends.py Loading commit data...
uploads.py Loading commit data...
urlutils.py Loading commit data...
video.py Loading commit data...
vllm_worker.py Loading commit data...
voice_clone.py Loading commit data...
voice_convert.py Loading commit data...
vpr_salad_server.py Loading commit data...
xtts_worker.py Loading commit data...