Skip to content

Memory pressure: the warm pool pauses and sheds idle devices #1363

Closed

Description

@V3RON

Part of #1355.

Scope

At warming-paused (and above), the warm pool starts nothing and gives memory back. It proposes no boot and no creation for configured targets, learned kinds or queued requests. On each reading while the step holds, it shuts down one idle device. A target left short reports memory-pressure. When the step lifts, the pool runs a pass at once and fills again. Leasing's own creates and boots are as today at this step.

In short

flowchart LR
  R[reading while warming paused] -->|*new* port onReading, after start| P[warm pool pass]
  L[memory.pressure-changed] -->|*new* trigger| P
  P --> F{plan}
  F -- boots, creations --> N[none proposed *new*]
  F -- shed *new* --> S[shut down one idle device: no configured count keeps it first, then configured; least recently used first; never one a waiter would take]
  P --> T[targets short: memory-pressure *new*]
Loading

An idle device is a virtual device that is ready, unleased and unclaimed. Shed means shut it down; the disk stays until the reaper's idle rules delete it, as today. One shed per reading means at most one per 15 s, however many passes run in between; the reading counts as used when the shed is proposed.

The order: first every idle device no configured target keeps (a configured target keeps its oldest count ready devices, by createdAt, as it does today, F13), then the kept ones, the devices of spared targets among them; least recently used first within each group. Never a device a waiting request would be granted. A device whose shutdown failed in the last 30 s is skipped, so the next reading takes the next one. While warming is paused, a short target reports memory-pressure in place of any reason evaluate decides (boot-failed, running-limit, device-limit, ram-budget, reserve). A target that does not resolve keeps its own reason (no-driver, runtime-missing, unknown-model, unresolvable, set by the converger, src/core/warm-pool/converger.ts:527): a pause would not fill it either.

# before, at pressure warn
$ simlock status
Capacity ios: managed 3/6, running 3 + 0 reserved/6, warm 3

# after, three readings later
$ simlock status
Memory pressure: warming paused since 09:12 (pressure warn)
Capacity ios: managed 3/6, running 0 + 0 reserved/6, warm 0

If this goes wrong, the pool sheds a device a request was about to take, or keeps booting while memory is short.

Technical spec

Facts

Commit 6674ad0.

# Fact Source
F1 evaluate is pure over a WarmPolicyView: devices, leases, waiting demand, capacity, config, now, targets, learned kinds src/core/warm-pool/policy.ts:92-117
F2 Over budget, the policy proposes shutdowns of the least recently used running devices, never one a non-in-flight waiter is served by, reason over-budget src/core/warm-pool/policy.ts:268-285
F3 TargetShort lists the short reasons; a capacity refusal maps to one through shortOf, ram-budget and device-limit kept, the rest running-limit src/core/warm-pool/policy.ts:53-60, src/core/warm-pool/policy.ts:589-591
F4 The wire's short is warmPoolShortSchema src/contract/status-schemas.ts:53-64, src/contract/status-schemas.ts:77
F5 warm-pool.target-missed carries a free reason string; the website lists its values src/bus/index.ts:298-307, website/src/content/docs/docs/reference/events.mdx:128
F6 The pool boots under tryReserveBoot and creates under tryReserveProvisioning src/core/warm-pool/converger.ts:781, src/core/warm-pool/converger.ts:819
F7 A pass runs on bus facts (capacity.changed among them), a 30 s tick and core.passWarmPool() src/core/warm-pool/converger.ts:941, src/core/warm-pool/converger.ts:98, src/core/create-core.ts:423
F8 The policy test asserts the over-budget shutdown order and waiter shield src/core/warm-pool/policy.test.ts:412
F9 The converger test drives proposals into actions with the warm-pool initiator under the cleanup claim src/core/warm-pool/converger.test.ts:103
F10 The pool boots for a waiter through bootForWaiter and creates through createForWaiter, two paths src/core/warm-pool/policy.ts:365-383, src/core/warm-pool/policy.ts:385-409
F11 The pool's bus triggers do not include memory.pressure-changed; it starts only inside core.converge, and the sampler starts before converge src/core/warm-pool/converger.ts:932-943, src/core/create-core.ts:416-420, src/daemon/server.ts:414, src/daemon/server.ts:427
F12 The pool is built in createCore and in its test fixtures src/core/create-core.ts:295, src/core/warm-pool/test-fixtures.ts:362
F13 A target keeps its oldest count ready devices src/core/warm-pool/policy.ts:476-493

Modules touched

Searches: TargetShort, shortOf, overBudget, warmPoolShortSchema, WarmPolicyView, passWarmPool, "over-budget" across src/, ui/, website/.

flowchart LR
  CC[core create-core *] --> WC[warm-pool converger *]
  WC --> WP[warm-pool policy *]
  WC --> MP[core memoryPressure port, #1361]
Loading

Contract and event changes

none: memory-pressure is in warmPoolShortSchema from #1361. warm-pool.target-missed gains the reason value memory-pressure (its payload's reason is a free string, F5); its EVENTS.md row and the website's list name it.

Other code on the same state

Searches: proposals of action: "shutdown" in policy.ts (3 hits: disabled, over budget, never-leased idle, displacement); readers of idle ready devices (targeted(), the reaper's idle-shutdown).

Failure modes

Call Outcome What happens Limit, counted from
pass → memoryPressure() port warming-paused or higher no boot or creation; one shed per new reading each pass
pass → memoryPressure() port none or undefined as today each pass
shed → lifecycle.shutdown fails logged, the pool's failed-shutdown pause, as today; that device is skipped by the next sheds 30 s from the failure
port onReading a reading before start() nothing: not subscribed yet none

The last-shed readingAt is memory only; a restart may shed once on its first reading, which is the same cadence.

Rules in play

  • ADR 0068 §3: "never a device a waiting request would be granted"; the shed skips the devices the over-budget shield skips (F2).
  • Warm pool manual: "Only displacement shuts a device down for a target or learned kind"; the shed is a pressure shutdown, not for a target, and ADR 0068 §3 puts configured targets' devices last.
  • Warm pool manual: "policy.ts is pure"; the shed decision reads the step and the last shed from the view.
  • ADR 0017: the pool acts beside the lease transaction; a shed takes no lease-path lock beyond the existing cleanup claim.

Tests

The seam is evaluate for what is proposed, modelled on src/core/warm-pool/policy.test.ts, and WarmPool with a fake port and the bus for the cadence and the event, modelled on src/core/warm-pool/converger.test.ts.

  • At warming-paused the warm pool starts nothing and reports why: configured target short; learned kind short; a queued request's creation not proposed; a queued request's boot of a shut-down device not proposed; targets report short: "memory-pressure", also when also short for reserve, and a runtime-missing target keeps runtime-missing (at the WarmPool seam); warm-pool.target-missed reason memory-pressure (at the WarmPool seam).
  • Each reading while warming is paused shuts down one idle device, in order: through the port's onReading, one per reading, a device no target keeps (least recently used first), then a kept configured one; a device a waiter would take skipped; a device whose shutdown just failed skipped; two passes on one reading shed one; a reading before start() sheds nothing; nothing idle sheds nothing; step none sheds nothing.
  • When warming resumes the pool fills its targets again: memory.pressure-changed to none runs a pass that boots or creates for a short target, with no tick.

Done when

  • pnpm exec vitest run --project unit src/core/warm-pool/policy.test.ts src/core/warm-pool/converger.test.ts passes.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 6, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 6, 2026
  3. self-assigned this
    on Nov 6, 2026
  4. added 19 commits that reference this issue on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions