Repository navigation
Description
Request: #1550
Problem
On a Mac that runs builds beside a warm iOS pool, every lease grant is followed by about 90 seconds in which the host has no idle CPU. The cause is the warm pool's refill: right after the grant it boots the next warm device, and that first boot takes about half of a 10-core Mac. The build beside the pool loses more than half of its CPU, and the agent that just got the lease starts its app on a starved host, once per lease. No warmPool setting changes when that boot runs.
Who it is for
An operator of a Mac shared by coding agents and CI jobs: agents lease simulators from the warm pool while native builds run on the same host, and leases come in all day.
Outcome
After a lease is granted, the warm pool waits a fixed time before it boots or creates the next warm device, so the lessee's first app start and the builds beside it get the CPU first. This is on by default. A request that is waiting for a device is never made to wait longer by it. An operator can change the wait, or set it to 0 for today's behaviour.
How it works for the user
sequenceDiagram
participant A as Agent
participant W as Worker
participant P as Warm pool
A->>W: lease (a warm device is ready)
W-->>A: granted at once
Note over P: refill held for warmPool.refillDelayMs (60 s)
A->>W: second lease of the same kind, inside the 60 s
W->>W: no warm device: boots one for the request at once (not held)
W-->>A: granted after the boot
Note over P: the 60 s end (counted from the latest grant)
P->>P: boots or creates the missing warm devices
Before, a few seconds after a grant:
$ simlock status
warm pool: enabled, reserve ios 0
iPhone 17 / 27.0 / slim configured wanted 1 ready 0 booting 1
After, in the first 60 s after a grant:
$ simlock status
warm pool: enabled, reserve ios 0
iPhone 17 / 27.0 / slim configured wanted 1 ready 0 booting 0
and once the 60 s are over, booting 1, then ready 1, as before.
A bad value stops the daemon from starting, with the message every number key uses:
$ simlock daemon start
Invalid config value for "warmPool.refillDelayMs": expected a non-negative number
Examples
warmPool.refillDelayMs in config.json:
| Input | Today | After |
|---|---|---|
| key absent | the key does not exist; refill at once | 60 s wait (60000) |
60000 |
warning Unknown config key: "warmPool.refillDelayMs", ignored |
60 s wait |
0 |
warning, ignored | no wait: refill at once, as today |
1500.5 |
warning, ignored | 1.5005 s wait (same rule as idle.shutdownAfterMs) |
-1 |
warning, ignored | refused: expected a non-negative number |
"60s" |
warning, ignored | refused: expected a non-negative number |
What starts the wait, with the default 60 s:
| Event | Today | After |
|---|---|---|
| a lease of a simulator or emulator is granted at t=0 | refill boot at once | refill at t=60 s |
| a second such grant at t=30 s | refill at once | refill at t=90 s |
| a lease of a physical device is granted | no refill (nothing warm was spent) | no wait starts |
| a lease is released, a device deleted, the daemon starts, outside any wait | refill at once | refill at once: these start no wait |
| the same events inside a wait | refill at once | held until the wait ends: they do not end it |
| a request queued during the wait, its device shut down or not yet made | boot or creation at once | boot or creation at once |
| the daemon restarts inside the wait | refill at once after the start | refill at once after the start |
What could go wrong
- A second lease of the same kind inside about two and a half minutes of the first (60 s wait plus the boot) finds no warm device and waits for a boot, where today it waits only inside the 90 s boot. Likely on busy hosts; the operator can lower the wait.
- With grants coming more often than once a minute all day, the pool never refills; each lease then boots its own device, as with no warm pool. Rare; set the wait lower or to 0.
- For up to 60 s after a grant,
simlock statusshows a warm line short of its count with no reason. Harmless, may puzzle an operator.
Words used
- refill: the boot or creation the warm pool starts to bring a warm line back to its count, for example booting a new iPhone 17 after the only ready one was leased.
- warm line: a configured target or a learned kind in
simlock statusunderwarm pool. - waiting request: a lease request with no device yet, queued or being served, for example a second
simlock lease ioswhile no warm device is ready. - refill wait: the time after the latest grant of a simulator or emulator during which the warm pool starts no refill (
warmPool.refillDelayMs).
Non-goals
- No host CPU gate or load reading: the wait is fixed.
- No wait for a boot or creation that serves a waiting request.
- No wait after a release, a deletion or a daemon start.
- Nothing kept across a daemon restart: a restart inside the wait refills at once.
- Wallpaper work in slim mode: shipped with slim
include/exclude(feat(ios): slim worker include and exclude lists of single services #1655). - No new short reason in
simlock statusand no event for the wait.
Completion conditions
- With default settings, after a simulator lease is granted, the warm pool starts no refill for 60 s, and starts it when the 60 s end.
- A lease requested during those 60 s, with no warm device ready, is served by a boot or creation that starts at once.
warmPool.refillDelayMs: 0refills at once after a grant, as before this feature.simlock config getlistswarmPool.refillDelayMs, and a negative or non-number value stops the daemon with the message above.- The configuration reference and the warm pool pages describe the key and its default.
Open questions
none
Decisions
- No new ADR: one config key and one hold in the warm pool's plan, cheap to reverse. ADR 0017 (warm pool beside the lease transaction) and ADR 0038 (it boots for every queued request) are unchanged: a pass still runs on
lease.grantedand still serves the queue. - Approved by the maintainer in the spec session (2026-11-25): the design and every
Decided in the sessionline below. - Maintainer decision (2026-11-24, comment on Warm pool: the refill boot after every lease grant takes half of a 10-core Mac for 90 s, and nothing paces it #1550): a fixed refill delay after each lease grant, on by default; a boot for a waiting request is never delayed; no CPU gate.
- Decided in the session: the default is 60 s (
60000), because the lessee's install and first app start fall inside the first minute after a grant in the request's measurements, and one round minute keeps the next warm device ready about 150 s after a grant (60 s plus the ~90 s boot). - Decided in the session: the wait is counted from the latest grant and holds every warm line on both platforms, because the boot competes for the whole host's CPU, whatever its platform.
- Decided in the session: only a grant of a simulator or emulator starts the wait, because a physical lease spends no warm device and is followed by no refill.
- Decided in the session: the time is kept in memory only, because a restart already boots what the pool lacks and a lost wait costs one early boot.
- Decided in the session: during the wait a warm line is not reported short and
warm-pool.target-misseddoes not fire, because the line is filling on a schedule, not failing; a new short reason would also change the status contract for a minute-long state. - Decided in the session: memory pressure still wins: a line held by both reports
memory-pressure, as today. - Decided in the session: the value follows
idle.shutdownAfterMs: a non-negative number of milliseconds, no upper bound. - Decided in the session: the wait also holds a target's displacement (shutting down a learned device to make room), because displacement exists only to make room for a refill.
Behaviours
| Id | Behaviour (invoker, action, what it sees) | Seam | Cases | Task |
|---|---|---|---|---|
| B1 | A simulator or emulator lease is granted; the warm pool proposes no boot or creation for any configured target or learned kind until refillDelayMs after the latest such grant, then proposes it. During the wait each held line has no short and no warm-pool.target-missed fires. |
WarmPool (src/core/warm-pool/index.ts) with a fake clock and bus |
configured target with a shut-down device to boot; configured target needing a creation; learned kind's spare (max(peak − leased, 1)); a pass at 59 999 ms proposes nothing and the timer's pass at 60 000 ms proposes the refill; a second grant at 30 000 ms moves it to 90 000 ms; an iOS grant holds an Android target too; a physical device's grant starts no wait; a target that would displace a learned device proposes no displaced shutdown during the wait; at memory pressure warming-paused the held target reports memory-pressure |
#1838 |
| B2 | During the wait, a waiting request's boot or creation and the plan's shutdowns run as today. | WarmPool (src/core/warm-pool/index.ts) with a fake clock and bus |
a queued waiter matched to a shut-down device gets a waiting-request boot; a non-head waiter gets a waiting-request creation; an over-budget shutdown and a never-leased-idle shutdown are still proposed |
#1838 |
| B3 | With refillDelayMs: 0 a grant holds nothing; a pool that saw no grant since it started holds nothing. |
WarmPool (src/core/warm-pool/index.ts) with a fake clock and bus |
0 and a grant: the pass on lease.granted proposes the refill; a fresh pool with the default and no grant proposes its targets on daemon.started; dispose() cancels a pending wait timer |
#1838 |
| B4 | An operator writes warmPool.refillDelayMs in config.json; the config loads it, or refuses it with Invalid config value for "warmPool.refillDelayMs": expected a non-negative number; config.get answers it. |
loadConfig (src/core/index.ts) and the config.get output schema (src/contract/config-schemas.ts) |
absent → 60000; 0; 1500.5; -1 refused; "60s" refused; config.get keeps the value through its output schema |
#1838 |
Stored state
none
Interfaces
| Id | What | Shape and bounds | Errors and limits | Where | Task | Used by |
|---|---|---|---|---|---|---|
| I1 | warmPool.refillDelayMs, a worker config key |
non-negative number of milliseconds, optional in config.json, default 60000 from defaultWarmPoolConfig; required (readonly refillDelayMs: number) in WarmPoolConfig, as maxConcurrentBoots is, so the loaded config, GatewayConfig (z.infer of the config.get answer, src/gateway/dispatcher.ts:94, src/daemon/main.ts:567) and I2 agree; 0 turns the wait off |
Invalid config value for "warmPool.refillDelayMs": expected a non-negative number (config load) |
WarmPoolConfig, defaultWarmPoolConfig and warmPoolConfigValidator (src/core/warm-pool/config.ts) |
#1838 | — |
| I2 | config.get answer: warmPool.refillDelayMs |
z.number(), required in the answer (the loaded config always has it); bumps the protocol by one |
— | src/contract/config-schemas.ts, src/contract/protocol.ts |
#1838 | — |
| I3 | WarmPolicyView.refillHeldUntil |
optional number, a clock time in ms; absent or ≤ now holds nothing |
— | src/core/warm-pool/policy.ts (read by holdFill), set by WarmPool.#view (converger.ts) |
#1838 | — |
Existing code
Commit 200afe5.
Searches: rg "lease.granted" src -g '!*.test.ts' (30 hits, the pool's in converger.ts:233 and :984); rg "maxConcurrentBoots|baselineLearnAfter" src website docs/internal -g '!*.test.ts' (31 hits: config, schema, fixtures, docs); rg -n "reason:|action: \"" src/core/warm-pool/policy.ts (proposal kinds); open PRs touching warm-pool, config-schemas or protocol.ts (#1770, #1809, #1499).
| Id | Code (path:line) | Today | With this feature | Handled by |
|---|---|---|---|---|
| X1 | src/core/warm-pool/converger.ts:233 #subscribeLearning, lease.granted |
learns the kind of a virtual device's grant; a physical device is skipped as it is not in virtualDevices |
the same handler, or one beside it, records the grant time of a virtual device and arms the wait timer when refillDelayMs > 0; bus subscribers run inside emit (src/bus/AGENTS.md), so the time is set before the pass lease.granted starts reads it |
B1, B3 |
| X2 | src/core/warm-pool/converger.ts:980 TRIGGERS, :193 |
lease.granted starts a pass at once |
unchanged: the pass still serves the queue and shuts devices down; only fills are held | B2 |
| X3 | src/core/warm-pool/policy.ts:754 holdFill |
holds a target for memory pressure (first), a waiter it could not serve, then the retry schedule | adds the refill hold after the pressure check: { added: 0 }, no short, while now < refillHeldUntil; fillTarget (:770) returns before addDisplacing, so no displacement either |
B1 |
| X4 | src/core/warm-pool/policy.ts:335 boots (waiting-request boot :404, creation :424) |
serves the queue at pressure.step === "none" |
unchanged: never reads the refill hold | B2 |
| X5 | src/core/warm-pool/policy.ts:160 evaluate: over-budget, never-leased-idle, memory shed |
proposed every pass | unchanged | B2 |
| X6 | src/core/warm-pool/converger.ts:432 #armRetry, :311 dispose |
one retry timer, cancelled by dispose; #trigger does nothing while draining or disposed |
a second timer the same way, for the wait's end, re-armed by each grant and cancelled by dispose |
B1, B3 |
| X7 | src/core/warm-pool/converger.ts:650 #view |
builds the policy view with now |
adds refillHeldUntil (I3) |
B1 |
| X8 | src/core/warm-pool/config.ts:34, :49, :116 |
WarmPoolConfig, defaults, validators; src/core/config-defaults.ts:97 spreads defaultWarmPoolConfig, src/core/config-validators.ts:193 spreads the validators |
adds refillDelayMs (I1), nonNegativeNumber as idle.shutdownAfterMs uses (config-validators.ts:191) |
B4 |
| X9 | src/contract/config-schemas.ts:78, src/contract/protocol.ts:13 ({ min: 102, max: 102 }) |
the warmPool answer schema lists every key; an undeclared field is stripped (src/contract/AGENTS.md) |
adds the field; protocol +1 | B4 |
| X10 | src/core/warm-pool/test-fixtures.ts:311, src/core/warm-pool/test-policy.ts:211, and every hand-built warmPool config: src/leasing/test-create-leasing.ts:76, src/leasing/test-lease-acquisition.ts, src/leasing/test-lease-end-participants.ts, src/leasing/test-physical-device-watcher.ts, src/core/test-doctor.ts:108, src/core/reaper.test.ts:85, src/core/nuke.test.ts:330, src/leasing/physical-leasing.test.ts:69 (found by rg -l "maxConcurrentBoots: 1" src) |
build a WarmPoolConfig by hand |
the field is required (I1), so each sets it: the two warm-pool fixtures take a refillDelayMs option that defaults to 0, the others write refillDelayMs: 0, so today's tests keep refilling at once; B1's cases pass the default 60000 |
B1, B3 |
| X11 | website/src/content/docs/docs/reference/configuration.mdx:128, website/src/content/docs/docs/worker/warm-pool.mdx:66, website/src/content/docs/docs/concepts/warm-pool.mdx |
list every warmPool key |
a row for the key and a line on the wait after a grant | — |
| X12 | src/core/warm-pool/AGENTS.md (the plan rules) |
lists what holds a fill | one line for the refill hold | — |
| X13 | e2e/helpers/env.ts:240 STANDALONE_OFF, merged into every worker's seeded config.json (seedConfig, :245); readers that wait for a refill right after a grant: e2e/warm-pool-learned.test.ts:57-67, e2e/warm-pool-reserve.test.ts:104-120, e2e/doctor-drift.test.ts:78, e2e/lease-lifecycle.test.ts:254, slow lane e2e/slow-warm-pool.test.ts:724 |
the e2e daemons run the default warm pool, which refills at once | STANDALONE_OFF adds warmPool: { refillDelayMs: 0 }, so every e2e flow, fast and slow lane, refills at once as today and none of these tests changes; the wait itself is proven by B1 at the WarmPool seam |
B3 |
Tasks
- Warm pool: wait warmPool.refillDelayMs after a lease grant before refilling #1838 Warm pool: wait
warmPool.refillDelayMsafter a lease grant before refilling — after a simulator or emulator grant the warm pool waits 60 s (configurable,0off) before it refills, and a waiting request is never held. Risk: a waiting lease is held up by the wait, or the pool never refills after a grant.
Every completion condition is delivered by #1838.
Open work in the same area:
- feat(core): core settles quick seeds in the background, one at a time, when the worker is quiet #1770 (seed settling, task Core settles quick seeds in the background, one at a time, when the worker is quiet #1746): its
create-leasing-warm-pool.test.tscounts the pool's timers afterdispose; the new wait timer is armed only on a grant and cancelled bydispose, so no Depends on; a rebase may need that count read again. - feat(auth): add read-only viewer role for fleet inspection and console #1809, feat(backends): persist device backend ownership #1499: each bumps
PROTOCOL_VERSION_RANGE; whichever lands later takes the next number. No Depends on: a one-line conflict. - Runtime warm-pool targets: warm.set and warm.list, kept in state.db #1143, Warm-pool targets over HTTP and the CLI #1144, Console: edit the warm pool's targets on a worker's Warm pool tab #1145 (runtime warm-pool targets,
task:draft): change where targets come from, not when they fill. No Depends on.
Written by an agent.
Activity
V3RON commentedon Nov 24, 2026
Design posted: business sections, Decisions, Behaviours B1–B4, Interfaces I1–I3, Existing code X1–X12. One task planned; checking against the code next.
Written by an agent.
V3RON commentedon Nov 25, 2026
Spec updated: design approved; Decisions gains the approval line; Behaviours and Interfaces name task #1838; Tasks filled with #1838 and the open work beside it.
Written by an agent.
V3RON commentedon Nov 25, 2026
Delivery run
Merged: none
Parked: #1838 (PR #1848, draft): the review cap is reached and R1's behaviour fix never had a code lens, because auto mode refused the
code-reviewerspawns.Waiting: none
Decided: none
Written by an agent.
feat(warm-pool): wait refillDelayMs after a lease grant before refill…
V3RON commentedon Nov 25, 2026
Delivery run
Merged: #1848 (#1838)
Parked: none (#1838 was parked earlier and resumed once the maintainer asked for the missing code check)
Waiting: none
Decided: none
Asleep: 14 min
Written by an agent.
github-actions commentedon Nov 25, 2026
Closing: all 1 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on
main. Flip its ADRs to Accepted if delivery has not.