Skip to content

A shut-down device still counts against the RAM budget #779

Closed

Description

@V3RON

What happens

A shut-down virtual device still counts against the RAM budget, so the resource capacity strategy can refuse a boot or a creation for ram-budget while nothing is running.

Where

  • src/core/capacity/limits.ts:70-72 activeDevices is every device not deleted, shut down included.
  • src/core/capacity/strategies/resource/index.ts:100-105 sums #bytesPerDevice over activeDevices.
  • src/core/capacity/AGENTS.md, "Strategies": "Used = sum over every device not deleted (shut down included)".

What a user sees

With the default idle.deleteAfterMs of 60 minutes, a worker that leased many kinds in an hour holds them shut down on disk, and a new request can be refused for RAM (simlock status shows atRamBudget) although the machine has the memory free. The warm pool reports a target short: ram-budget in the same state. Shutting an idle device down frees its running slot but not its RAM share; only the delete does.

Whether this is the intended meaning of the budget (a disk-and-RAM ceiling) or a defect is for triage; the docs describe the behaviour, so it may be a gap in the budget's design rather than in the code.

Found

Exploring the warm pool for #771 on 2026-10-20, at commit 97bc8ea.

Written by an agent.

Activity

  1. added
    bug:new
    and removed
    bug:new
    on Oct 20, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. V3RON commented on Oct 21, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed; proposed change: shutdown devices should consume no RAM budget. This expectation changes the documented policy.

    Test and reproduction-only commit, branch bug/779-repro. Title: “releases shutdown devices' RAM for status, provisioning and slim boots”.

    pnpm exec vitest run --project unit src/core/capacity/shutdown-ram.test.ts
    1 failed test; five named assertion failures:
    RAM used: expected 0; received 8589934592
    atRamBudget: expected false; received true (iOS and Android)
    provision and slim boot: expected ok:true; received ram-budget
    

    Three shutdown devices fill the nominal 8 GiB budget while running slots are zero. Empty-machine control requests succeed. Existing coordinator/resource tests: 32 passed. No hardware lane ran.

    Root cause

    Gap: the code implements its documented allocation policy. resource/index.ts:100 sums activeDevices, whose limits.ts:70 excludes only deleted devices. canBoot at line 62 assumes the device's current mode already holds RAM and charges only full-minus-current: a full shutdown boot adds zero. Status and admission consistently share this accounting; the symptom is not stale status.

    Simplest fix

    In one PR, exclude shutdown devices from RAM usage, retaining their device-limit charge. Charge shutdown boots their entire full size; retain the mode delta for running rewarms. Make boot reservations count as RAM-active at full size until released; changing mode alone currently leaves their state shutdown. Keep provisioning reservations charged. Update affected tests, the capacity manual and configuration docs. No fix is included here.

    Alternatives rejected

    • Exclude shutdown devices from activeDevices: also breaks device limits.
    • Filter RAM totals alone: loses boot-reservation protection and permits full boots without RAM checks.
    • Delete idle devices sooner: discards reusable devices and masks the accounting policy.

    Risk

    • Check simultaneous full/slim boots, reservations and release paths cannot overcommit.
    • Preserve running/device limits and rewarm accounting.
    • Confirm status and warm-pool admission still agree.

    Written by an agent.

  4. removed their assignment
    on Oct 21, 2026
  5. added
    bug:ready
    on Oct 24, 2026
  6. self-assigned this
    on Oct 24, 2026
  7. V3RON commented on Oct 24, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #979 (#779)

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions