• 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
..
conftest.py Loading commit data...
test_admin_auth.py Loading commit data...
test_admin_forward_auth.py Loading commit data...
test_admin_remote_ui.py Loading commit data...
test_audio_ml_backends.py Loading commit data...
test_audio_ml_endpoints.py Loading commit data...
test_autoupgrade.py Loading commit data...
test_autoupgrade_recovers_a_down_server.py Loading commit data...
test_autoupgrade_sees_training.py Loading commit data...
test_broker_config.py Loading commit data...
test_broker_dispatch.py Loading commit data...
test_broker_protocol.py Loading commit data...
test_broker_shutdown.py Loading commit data...
test_broker_streaming.py Loading commit data...
test_burst_placement.py Loading commit data...
test_character_studio_fetch.py Loading commit data...
test_cluster.py Loading commit data...
test_compose.py Loading commit data...
test_forward_auth_peer_trust.py Loading commit data...
test_front_api_auth.py Loading commit data...
test_front_ocr_swap_gate.py Loading commit data...
test_image_has_c_compiler.py Loading commit data...
test_longcat_avatar_layout.py Loading commit data...
test_longcat_bsa.py Loading commit data...
test_longcat_cancellable.py Loading commit data...
test_longcat_checkpoint_resolve.py Loading commit data...
test_longcat_component_quant.py Loading commit data...
test_longcat_config_ui.py Loading commit data...
test_longcat_external_training.py Loading commit data...
test_longcat_int8_load.py Loading commit data...
test_longcat_lora.py Loading commit data...
test_longcat_orchestration.py Loading commit data...
test_longcat_packaging.py Loading commit data...
test_longcat_placement.py Loading commit data...
test_longcat_progress.py Loading commit data...
test_longcat_prompt_cache.py Loading commit data...
test_longcat_quantize.py Loading commit data...
test_longcat_scale.py Loading commit data...
test_longcat_tasks.py Loading commit data...
test_longcat_variants.py Loading commit data...
test_longcat_vendored_source.py Loading commit data...
test_longcat_venv_env.py Loading commit data...
test_longcat_vram_estimate.py Loading commit data...
test_longcat_worker.py Loading commit data...
test_manual_multimodal_test_client.py Loading commit data...
test_model_scan_cache.py Loading commit data...
test_ocr_olmocr.py Loading commit data...
test_ocr_vram_share_and_fallback.py Loading commit data...
test_oom_priority.py Loading commit data...
test_remote_execution.py Loading commit data...
test_runpod_client_scale.py Loading commit data...
test_runpod_fleet_status.py Loading commit data...
test_runpod_global_volume.py Loading commit data...
test_runpod_ocr_remotization.py Loading commit data...
test_runpod_placement.py Loading commit data...
test_runpod_schedule_region_spend.py Loading commit data...
test_studio_composed_surfaces.py Loading commit data...
test_surya_runpod_fixes.py Loading commit data...
test_township_api_key.py Loading commit data...
test_township_clip_geometry.py Loading commit data...
test_township_longcat.py Loading commit data...
test_township_page_js.py Loading commit data...
test_township_templates.py Loading commit data...
test_township_video_dataset.py Loading commit data...
test_upgrade_launcher.py Loading commit data...
test_video_as_b64_scope.py Loading commit data...
test_video_geometry.py Loading commit data...
test_vllm_share_self_tuning.py Loading commit data...
test_vram_releasers.py Loading commit data...
test_weight_stores.py Loading commit data...
test_whisper_server_local_models.py Loading commit data...