Skip to content

feat(daemons): release managed model daemons under host memory pressure (#5818) - #6243

Merged
atomantic merged 3 commits into
mainfrom
claim/issue-5818
Sep 4, 2026
Merged

feat(daemons): release managed model daemons under host memory pressure (#5818)#6243
atomantic merged 3 commits into
mainfrom
claim/issue-5818

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

  • Adds memory-pressure-aware eviction pass to reapIdleDaemons in server/lib/managedDaemon.js:
    • Pure policy function evaluateMemoryPressurePolicy evaluating free memory threshold (4GB default), dead-band hysteresis (2GB default), sustained duration (30s default), and calm-down window (60s default).
    • Releases the least recently used unpinned daemon early when host memory is under sustained pressure, rather than waiting out the idle window.
    • Formats human-legible release reason ("released at HH:MM — host memory pressure").
    • Displays release reason warning text in the Models → LLMs runtime rows.
  • Adds per-runtime "Keep loaded" toggle to exempt daemons from both idle unloading and pressure-based eviction:
    • Settings updated in localLlmSettingsSchema for llama, mtplx, and slotstream.
    • Disables idle window input when "Keep loaded" is active.
    • Prevents --sleep-idle-seconds from being added to llama-server launch arguments when pinned.
    • Fail-safe handles isPinned() evaluation errors by treating daemons as pinned to avoid accidental evictions.

Closes #5818

Test Plan

  • Unit tests:
    • server/lib/managedDaemon.pressure.test.js: 18 tests covering memory pressure policy, hysteresis, calm-down, LRU ordering, pinned exemption, fail-safe error handling, and reaper integration.
    • server/services/llamaServerManager.test.js: verified --sleep-idle-seconds omitted when keepLoaded is configured.
    • client/src/components/settings/RuntimeServersCard.test.jsx: 31 tests covering "Keep loaded" toggle interaction and releaseReason rendering.
    • npm test -- lib/index.test.js: catalog and barrel export validation.

@atomantic

Copy link
Copy Markdown
Owner Author

Required code review was not completed before publication. This PR is intentionally left open and will not be merged until the required review completes.

…ail-safe

- evaluateMemoryPressurePolicy: track sustained-pressure samples against the
  hysteresis exit threshold (not the base threshold) once wasUnderPressure is
  true, so memory sitting in the dead-band still counts toward the sustained
  window instead of starving eviction indefinitely.
- reapIdleDaemons idle-timeout pass: skip a daemon that's already stopped
  instead of re-stopping it, which was overwriting a prior pressure-release
  reason and could preempt the pressure-aware pass on the same tick.
- reapIdleDaemons idle-timeout pass: fail-safe isPinned reads to true (pinned)
  on error, matching the pressure-aware pass, so a flaky settings read can't
  stop a keepLoaded daemon.
@atomantic
atomantic merged commit 1556632 into main Sep 4, 2026
12 checks passed
@atomantic
atomantic deleted the claim/issue-5818 branch September 4, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[repo-study-model-daemon-memory-pressure] Release managed model daemons under host memory pressure, not only after an idle timer

1 participant