Skip to content

Lighter, faster-to-reset devices for a pool of coding agents on one Mac #1049

Closed

Description

@Nabil372

The problem

We run up to about twenty coding agents on one Mac (M5 Max, 128 GB, Xcode 27.1, emulator 37.2.12), each leasing an iPhone simulator or an Android emulator from Simlock for app QA. Four things cost us memory or minutes per lease. Times below were taken while other work kept load averages between 11 and 220, so they spread.

  1. A new simulator pays a full first boot. simctl create plus the first boot takes 20-33 s, and a reclaim's erase brings that first boot back (a 16.7-19.7 s boot after an erase). A copy of a simulator that has already booted once boots in 1.5-5 s.
  2. New simulators cannot be slimmed before their first boot. Simlock's slim pass runs /bin/sh inside the simulator, and the iOS 26.5 (23F77), 27.0 (24A434) and 27.1 (24A94425) runtimes installed here have only df and launchctl in RuntimeRoot/bin (the comment at src/drivers/ios/index.ts:1056 saw a 27.0 with /bin/sh; ours has none), so on those runtimes a slim lease comes up full (2.4 GB settled on an iPhone 17). Tools such as simslim can switch services off while the simulator is shut down (0.65 GB settled), but Simlock offers no point between creating a device and its first boot to run one.
  3. An emulator's RAM, cores and metrics come from its device profile. The emulator's own -memory, -cores and -no-metrics flags cannot be set through the config, and RAM and cores decide how many emulators fit on one machine. A devices.xml profile can lower RAM but not cores, and every lease must then name that model.
  4. An emulator's reclaim depends on a snapshot. A reusable emulator is reset by loading its clean-baseline snapshot (one such load hung for 18 minutes here; reported separately); a fresh one boots twice to save that snapshot and is then deleted at release. With fresh emulators we saw 19-21 s per lease, 5.4 GB idle and 4.7 GB of disk per emulator. There is also no way to prepare an emulator once (switch apps and animations off, skip a browser's first run) and keep that state across leases.

Who runs into this

Teams that run many coding agents on one machine, each leasing a device for a short QA pass (lease, install the app, drive it, release), where memory decides how many agents run at once and a slow reset leaves agents waiting.

What you would like to happen

From the outside:

  1. A new simulator is ready in seconds, not after a first boot, without carrying any earlier lease's data.
  2. An operator can run a program of their own on a new simulator before its first boot (a slimming step, settings), with failures reported. This could fit Named baselines: a lease starts from a device the operator prepared #327's Named baselines design, though Named baselines: a lease starts from a device the operator prepared #327 rules out Simlock running setup: there it would be a baseline the operator slimmed while it was shut down, which Simlock then copies.
  3. An operator can set an emulator's guest RAM, cores and usage metrics in the config.
  4. An emulator can be prepared once (by a program of the operator's) and reset to that state on every lease, quickly and reliably. This could also fit Named baselines: a lease starts from a device the operator prepared #327, whose reclaim returns a device to its baseline, as long as the Android reset does not depend on a snapshot load.

With local patches these came to 9-18 s per new iPhone (0.65-0.73 GB settled; 30-40 s once per model to make the booted-once copy it is cloned from), and 7-16 s per Android lease after the first (35 s once at load 220; 2.1-2.3 GB idle, 1 GB of disk); an emulator's first lease, which prepares it, took 43-81 s.

Anything else

We run local patches for all four. The ones for points 2 and 4 (a program run before a simulator's first boot; emulators booted read-only from a disk prepared once) are on hold, so they don't run ahead of #327. For #327, or any of these, you're welcome to our measurements and the edge cases we found: an erase brings the first-boot setup back, so a clone source must never be erased; a read-only emulator's reclaim is a shutdown (0.6-1.8 s); a prepared disk holds across leases without a snapshot.

Related: #639 / #1041 (gRPC for emulators; #1042 duplicates #639), #327 (named baselines, which overlaps points 1, 2 and 4; there Simlock copies a device the operator prepared and runs no setup itself), #206 (iOS slim under load, which considers writing the overrides while the simulator is shut down), #1047 (a reclaim's snapshot load that hangs without limit) and #1048 (a new emulator making the others wipe).

Activity

  1. added
    request:new
    on Oct 29, 2026
  2. ericlitman commented on Oct 30, 2026

    @ericlitman

    We hit point 2 independently on Simlock 0.4.0 (Xcode 27.2, macOS 27.0.1, Apple silicon). The iOS 26.5 and 27.0 runtime roots here also have only df and launchctl in RuntimeRoot/bin, so every --mode slim lease logged Skipped iOS device slim ... exit 111 ... Invalid or missing Program/ProgramArguments and was granted full.

    Measurements, iPhone 17 on iOS 27.0, three runs per row. CPU is the device's launchd_sim tree, sampled every second from the lease (or create) until 60 s after the device was ready. Memory is simslim measure once booted.

    Path Ready in (median) Device CPU-s (median) Memory
    simlock lease, new device (falls back to full) 28 s 743 2.7 GB
    simlock release, then simlock lease again (erase, boot) 31 s 804 2.7 GB
    simlock lease, new device, with simslim watch --set <Simlock's device root> running 30 s 477 0.64 GB
    simlock release, then simlock lease again, with simslim watch running 23 s 168 0.64 GB
    simctl create, then simslim on (overrides written while shut down, one boot) 21 s 164 0.58 GB
    simctl clone of a slim template that booted once, plus its override file 2.4 s 136 not measured

    One finding that may help whoever picks this up: simslim keeps its overrides in /private/var/tmp/com.apple.CoreSimulator.SimDevice.<udid>/disabled.plist, outside the device folder, and that file survives the simctl erase in Simlock's reclaim. After the first slim, a reused device boots slim from the start: watch found 5 services to touch on the second boot instead of 155. So running simslim watch beside Simlock already brings reused devices to the cost of a freshly slimmed one, with no change to Simlock. It cannot avoid the full first boot of each new device; the copy-from-baseline path in #327 is what removes that.

    Side note: Simlock's copy of simslim's service list (slim-labels.ts, from simslim 65bda5b) predates three simslim fixes: gamed kept on (XCUITest launch delays, MobAI-App/simslim#57), assistantd kept on (a Spotlight memory leak, MobAI-App/simslim#59), and navd moved into widgets (MobAI-App/simslim#61).

  3. 0xdaniell commented on Oct 30, 2026

    @0xdaniell
    Contributor

    Numbers from one more setup: Intel macOS 26.7.1 VM, 8 vCPU, iOS 26.5, Xcode 26.6.

    first boot after create/erase     37 s
    slim pass (2 reboots)             about 25 s
    clone a booted-once data folder   1.4-2 s
    boot from that copy               10-14 s
    refill a warm slot: erase path    about 4 min under load
    refill a warm slot: copy path     65-93 s
    

    We copy the data folder in makeReady by a local patch, and also wait for agent-device's iOS runner there, because a device with no runner takes 20-90 s on its first snapshot. So for an agent, ready means the runner answers, not that the device booted. Neither has a seam today. Android has the same gap: helper APKs not in the clean baseline add 16 s to the first snapshot (17 s against 0.6 s).

    Written by an agent.

  4. V3RON commented on Nov 2, 2026

    @V3RON
    Contributor

    Point 2 of this request (slimming a new simulator before its first boot) is being specified in #1192: Simlock will write the launchd overrides while the simulator is shut down, ported from simslim, instead of running /bin/sh inside it. The other points stay open here.

    Written by an agent.

  5. github-actions commented on Nov 2, 2026

    @github-actions
    Contributor

    Shipped as #1192.

  6. V3RON commented on Nov 2, 2026

    @V3RON
    Contributor

    Points 1 and 4 of this request are specified in #327 (planned 2026-11-02, ADR 0061): every new simulator or emulator is a copy of a device that already booted once, an Android reset no longer loads a snapshot into a running emulator or wipes, and an operator can save a prepared device as a named baseline that leases copy. Point 2 is #1192; the pre-boot program is #1202. Point 3 (emulator RAM, cores and metrics in the config) is not taken up yet. This issue stays open until they ship.

    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

No one assigned

    Labels

    request:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions