Repository navigation
Description
Request: #1687
Problem
A worker can't choose how many CPU cores its Android emulators get. Every built-in device profile sets 4 cores, the seed every emulator is copied from carries that, and its boot snapshot is saved with 4 cores. android.emulator only has headless, gpu, audio and bootAnimation.
On a shared Mac this makes Android the biggest CPU user per device. In #1687, a 14-core Mac Studio runs 4 emulators (16 vCPUs) beside 9 iOS simulators: load average bursts to 72 while memory is fine. In #1587, a Mac that also runs CI jobs and native builds stopped running Android emulators at all. Both suites would run on 2 cores.
Passing the emulator's own -cores 2 at boot does not help: measured on emulator 36.5.11, a snapshot saved at 4 cores then fails to load, and every boot is a cold boot (18 s instead of 6 s).
Who it is for
The owner of a worker that shares its Mac with other heavy work: iOS simulators, CI jobs, native builds.
Outcome
The owner sets one number, and every Android emulator the worker makes from then on runs with that many cores. Those emulators still boot from their snapshot, as fast as today. With the setting unset, nothing changes.
How it works for the user
flowchart TD
A[Owner: simlock config set android.emulator.cores 2] --> B{Valid positive integer?}
B -- no --> C[Refused, exit 2, nothing written]
B -- yes --> D[Owner restarts the daemon]
D --> E[Next Android lease of each kind]
E --> F[Old seed is stale: made again at 2 cores, once]
F --> G[Device copied, boots from snapshot with 2 cores]
D --> H[Devices that already exist, warm spares included, keep 4 cores until released]
D --> I[Baselines saved at 4 cores list as stale; a lease naming one is refused]
H --> J[One of them saved as a baseline after the change: the baseline gets 2 cores]
Before:
$ simlock config set android.emulator.cores 2
{"error":{"code":"USAGE","message":"... Unknown config key: \"android.emulator.cores\" ..."}}
$ echo $?
2
After:
$ simlock config set android.emulator.cores 2
$ simlock daemon stop
$ simlock lease --platform android --device "Pixel 9" # held in one terminal
$ simlock adb shell nproc # in another
2
$ simlock config set android.emulator.cores 0
{"error":{"code":"USAGE","message":"Invalid config value for \"android.emulator.cores\": expected a positive integer"}}
The first lease of each kind after the change takes longer once while the seed is made again (a cold boot, a power-off and a snapshot boot).
Examples
android.emulator.cores |
Today | After |
|---|---|---|
| unset | 4 cores (the profile's) | 4 cores (the profile's), no seed made again |
2 |
refused: unknown key | 2 cores; seeds made again once |
1 |
refused: unknown key | 1 core |
4 with a 4-core profile |
refused: unknown key | 4 cores; seeds made again once, since the setting changed |
16 on a 14-core Mac |
refused: unknown key | accepted; 16 cores |
0, -1, 2.5, "2" (a string in the file), true |
refused: unknown key | refused: expected a positive integer |
2, then back to unset |
— | seeds made again at the profile's value |
2 with a devices.xml profile (its cores come from avdmanager) |
— | 2 cores: the worker setting wins |
2, then a 4-core device made before the change is saved as a baseline |
— | the baseline has 2 cores |
What could go wrong
- After the change, the first Android lease of each kind waits for a new seed. Expected, once per kind.
- A saved baseline made before the change can't be used until it's saved again. Likely for anyone who uses baselines; the stale reason and the docs say why.
- CPU-heavy work inside a 2-core emulator takes about twice as long (measured), so a tight test timeout may now fail.
- If the setting didn't reach the seed, devices would still have 4 cores with no error. The hardware check below catches that.
Words used
- core (vCPU): a CPU the emulator gives to Android inside it, e.g.
adb shell nprocprints4. Each one can keep one host core busy. - seed: the emulator Simlock makes once per model and system image and copies into every new device, e.g. the Pixel 9 / Android 36 seed.
- boot snapshot: the saved running state a copy starts from instead of booting Android from scratch. It only loads on the same core count it was saved with.
- stale: a seed or baseline whose snapshot no longer matches this worker's settings, e.g. after a
gpuchange. A stale seed is made again; a stale baseline is refused. - baseline: a device's disk saved by a user (
simlock baseline save) to start later leases from.
Non-goals
- Cores per lease or per profile (Android: allow setting the emulator's CPU core count #1587's first ask). One worker-wide number covers both requests: a 2-core worker has no 4-core emulator to hand out.
- Emulator RAM (
ramMbin Android: a worker setting for emulator CPU cores (profiles hard-code hw.cpu.ncore 4) #1687). - A
doctorcheck of emulator cores against host cores. - The CPU an emulator uses in the first minutes after it boots from its snapshot. That is being worked on separately.
- Changing devices that already exist. They keep their cores until released.
- Capping total CPU across emulators. The number of emulators running at once is already a capacity setting.
Completion conditions
- On a worker with
android.emulator.cores: 2, a new Android lease's device prints2foradb shell nprocand booted from its snapshot: the daemon log has nosnapshot-cold-bootdiagnostic for it. - On a worker upgraded with the setting unset, no seed is listed stale and none is made again.
simlock config set android.emulator.coreswith0,-1,2.5orabcexits 2 and writes nothing.- After the setting changes, a seed made before it is listed stale with
android.emulator launch settings changedand is made again at the next lease of its kind. A baseline made before it is listed stale with the same reason, and a lease naming it is refused. - A baseline saved after the change from a device made before it boots its leases with the new core count.
- The configuration reference lists
android.emulator.coreswith its type, default and meaning, says that only new devices get it, and says that seeds are made again and older baselines go stale.
Open questions
Decisions
- No ADR: one setting under the existing rule that a seed whose launch settings changed is made again (ADR 0061, seeds and copies).
- Decided in the session (maintainer): worker-wide only; per-lease or per-profile cores stay out.
- Decided in the session (maintainer): the core count is written into the seed, never passed as
-coresat boot, because a snapshot saved at another core count fails to load (measured). - Decided in the session (maintainer): RAM, the
doctorcheck and the post-boot CPU stay out. - Decided in the session (maintainer): a baseline saved at another core count is stale and refused, the same as after a
gpuorheadlesschange today. - Decided in the session (maintainer): a baseline save writes the current
coresinto the saved copy before its snapshot boot, because a warm spare or a held lease made before the change would otherwise give leases the old core count with no error. - Decided in the session: with
coresunset, a baseline save leaves the device's own core count, because unset means Simlock does not manage cores. - Decided in the session: unset means the profile's own value and adds nothing to what a seed depends on, because an upgraded worker must not make every seed again.
- Decided in the session: the setting wins over every profile kind (built-in, the SDK's, devices.xml), because the owner sets it for the host, not for a model.
- Decided in the session: no upper bound, because a value above the host's cores is the owner's choice and the emulator accepts it.
- Decided in the session: devices that already exist keep their cores until released, because the core count is in each device's own files, copied from its seed, and changing it would make its snapshot fail to load. This differs from
headlessandgpu, which are boot flags and reach an existing device at its next boot. - Decided in the session: the stale reason stays
android.emulator launch settings changed, because it already names the section the owner changed. - Decided in the session: no protocol bump, because
config.getcarries a driver's own keys as sent.
Behaviours
| Id | Behaviour (invoker, action, what it sees) | Seam | Cases | Task |
|---|---|---|---|---|
| B1 | An owner sets android.emulator.cores: a positive integer is written; anything else is refused with Invalid config value for "android.emulator.cores": expected a positive integer, exit 2, nothing written. A daemon loading a config file with a bad value refuses it with the same message. |
runCli(["config", "set", …]) with the real config loader; the config loader (loadConfig) |
2 written; 1 written; 0, -1, 2.5, abc refused; file value "2" (string) and true refused at load; key unset loads with no cores |
#1740 |
| B2 | With cores set, a new seed's config.ini holds hw.cpu.ncore=<cores> before its first boot, for every profile kind; with it unset, the profile's own value, as today. |
Android driver provision (test-driver-harness.ts with emulator options, faked SDK and filesystem) |
built-in profile (4) with cores: 2 → 2; SDK profile from avdmanager with cores: 2 → 2; devices.xml profile with cores: 2 → 2; built-in profile, cores unset → 4 |
#1740 |
| B3 | A seed or baseline made under another cores value is stale with android.emulator launch settings changed: a seed is made again at the next provision of its kind, a baseline is listed stale and a lease naming it refused. Unset on both sides is not stale, and the seed's fingerprint is the one today's code computes. |
Android driver listSources / provision (test-driver-harness.ts, the driver restarted with new emulator options over the same root), so the mapping from options runs |
made unset, now unset → not stale; made with headless: true and cores unset, now the same → not stale, fingerprint equal to today's for headless: true; made unset, now 2 → stale; made 2, now 2 → not stale; made 2, now 3 → stale; made 2, now unset → stale; baseline made unset, now 2 → listed stale and its provision refused |
#1740 |
| B6 | A baseline save, with cores set, writes hw.cpu.ncore=<cores> into the saved copy before its snapshot boot; with it unset, the copy keeps the device's own value. |
Android driver saveSource (test-driver-harness.ts) |
device made at 4, saved with cores: 2 → the source's config.ini says 2, listed not stale; device made at 2, saved with cores: 2 → 2; device made at 2, saved with cores unset → 2 |
#1740 |
| B4 | A device copied from a seed made with cores: 2, or from a baseline saved under it, boots from its snapshot with 2 cores. |
Hardware: one real emulator on this Mac, default image | from the seed: adb shell nproc prints 2, no snapshot-cold-boot diagnostic in the daemon log for that boot; from a baseline saved from a device made before the change: the same |
#1740 |
| B5 | The configuration reference and the worker configuration page describe the setting. | website pages reference/configuration.mdx, worker/configuration.mdx |
the key row (type, default, meaning); the note under the table says cores reaches new devices only, existing ones keep theirs, seeds are made again once and older baselines go stale, while the other android.emulator.* keys still apply at each emulator's next boot; a task row "Give Android emulators fewer cores" |
#1740 |
Stored state
| Id | What and where | Created, changed, deleted by | Listed or swept by | A restart mid-step leaves | Schema step | Task | Used by |
|---|---|---|---|---|---|---|---|
| S1 | android.emulator.cores in the worker's config.json |
The owner, by simlock config set or by hand; read at daemon start only |
simlock config get |
— | none | #1740 | — |
| S2 | The hw.cpu.ncore line in a seed's or a baseline source's config.ini (existing file, existing line) |
Seeds while it makes a seed, after the profile's values are written, and while it saves a baseline, after the copy and before the snapshot boot; copied into every device made from that source |
Part of the source's config hash (X3) | A source being made or saved is a making row, swept at the next listing or make of its kind, as today |
none | #1740 | — |
Interfaces
| Id | What | Shape and bounds | Errors and limits | Where | Task | Used by |
|---|---|---|---|---|---|---|
| I1 | Config key android.emulator.cores |
Optional integer ≥ 1, no upper bound; no default (absent means the profile's value); worker only | Invalid config value for "android.emulator.cores": expected a positive integer (existing positiveInteger message); config set exits 2 with USAGE |
src/drivers/android/definition.ts |
#1740 | — |
| I2 | What a seed's snapshot depends on gains cores=<n> when the key is set; nothing when unset |
String cores=<n>; absent when unset, so today's hash is unchanged, with any headless and gpu |
— | seedLaunchInputs, src/drivers/android/index.ts |
#1740 | — |
| I3 | AvdConfig carries the core count to Seeds: a new optional cores in AvdConfigOptions, set from android.emulator.cores where AvdConfig is built, and one method that writes hw.cpu.ncore=<cores> into a folder's config.ini when set and does nothing when unset |
cores?: number (integer ≥ 1, validated by I1) |
A line break or NUL is already refused by #mergeConfigIniLines; a number cannot hold one |
src/drivers/android/avd-config.ts, built at src/drivers/android/index.ts:218-224 |
#1740 | — |
Existing code
Commit c1130b8.
Searches: ncore in src (19 hits: 17 profiles, hardware-keys.ts, a fixture), seedLaunchInputs (5 hits in non-test code), configHash in src/drivers/android (17 hits), applyLibraryProfile|applyHardwareProperties (3 call sites), android.emulator in website/src/content/docs (3 pages).
| Id | Code (path:line) | Today | With this feature | Handled by |
|---|---|---|---|---|
| X1 | src/drivers/android/definition.ts:17-23,47,52-57 |
AndroidEmulatorLaunchOptions has 4 keys; objectValidator warns on any other key, so config set refuses cores |
Adds optional cores with positiveInteger (src/core/validation.ts:62); not in the defaults |
B1, I1 |
| X2 | src/drivers/android/index.ts:902-912 seedLaunchInputs |
[] while headless and gpu are at their defaults, else headless=…, gpu=… |
Adds cores=<n> when set; at all defaults and unset still [] |
B3, I2 |
| X3 | src/drivers/android/avd-config.ts:65-75 currentConfigHash |
Hashes the image, the emulator version, the seed's hw.* lines and seedLaunchInputs |
Unchanged; the new input and the new hw.cpu.ncore value flow through it |
B3 |
| X4 | src/drivers/android/seeds.ts:550-563 seed make; SeedsOptions at :76-94 has no launch options |
avdmanager create, then devices.xml profiles get applyHardwareProperties, built-in ones applyLibraryProfile; SDK profiles get nothing |
After that, calls I3 for all three kinds, before the first boot; Seeds reaches the count only through its avdConfig |
B2, I3 |
| X13 | src/drivers/android/seeds.ts:262-308 saveSource |
Powers the device off, copies its folder (its config.ini keeps the device's hw.cpu.ncore), boots the copy once for its snapshot, then hashes it with today's inputs |
Calls I3 on the copy between the copy and #snapshotSource |
B6, I3 |
| X14 | src/drivers/android/device-profile-source.ts:617-630 devices.xml parser |
Writes only hw.device.*, hw.lcd.* and RAM, so a devices.xml profile's cores come from avdmanager |
Unchanged | B2 |
| X5 | src/drivers/android/avd-config.ts:28-40 applyLibraryProfile |
Writes the profile's hw.* (with hw.cpu.ncore=4) and drops other seed hardware lines |
Runs first; the cores line is written after it, so it is not dropped |
B2 |
| X6 | src/drivers/android/seeds.ts:222-249 #staleReasonOf, called at :444 (seed) and :483-488 (baseline) |
A hash mismatch is android.emulator launch settings changed; a seed is made again, a baseline refused |
Same paths; a cores change is a hash mismatch |
B3 |
| X7 | src/drivers/android/emulator.ts:364-373 emulatorLaunchFlags |
4 flags from the launch options | Unchanged: no -cores flag |
Decisions |
| X8 | src/drivers/android/data.ts:7 device configHash |
Stored per device, not checked at boot | Unchanged: an existing device keeps its cores until released | Decisions |
| X9 | src/drivers/android/seeds-copies.test.ts:117-133, test-seeds.ts:65-71 |
Stale-seed table that hands AvdConfig a written-out seedLaunchInputs list, never through seedLaunchInputs() |
Left as it is; B3 runs through the driver harness instead, so the mapping is tested | B3 |
| X15 | website/src/content/docs/docs/reference/configuration.mdx:234 |
"android.emulator.* changes apply at each emulator's next boot" |
True for the four boot flags only; B5 adds the cores exception |
B5 |
| X10 | src/cli/index-device-config.test.ts:342-345 |
config set good/bad table for ios.simulator.audio and android.emulator.headless |
Gains android.emulator.cores |
B1 |
| X11 | website/src/content/docs/docs/reference/configuration.mdx:219-236, worker/configuration.mdx:103,150-155 |
Rows and a note for headless, gpu, audio, bootAnimation |
B5 rows | B5 |
| X12 | src/contract/operations-round-trips-catalog-config.test.ts:480-492 |
config.get carries android.emulator as sent |
Unchanged; no shape change | Decisions |
Tasks
- Android: android.emulator.cores sets the cores of new emulators and baselines #1740 Android: android.emulator.cores sets the cores of new emulators and baselines — an owner sets one number and every new Android emulator, from a seed or a baseline saved after the change, runs with that many cores and still boots from its snapshot.
Risk: emulators keep 4 cores with no error, or every lease cold-boots after an upgrade.
Completion conditions: all delivered by #1740's Done when lines (the hardware one by its slow-lane line).
Open work in the same area: the post-boot CPU of Play Store copies is being worked on separately; it may change when a seed saves its snapshot (seeds.ts #bootToSnapshot), next to this task's change in the seed make. No Depends on: no issue for it exists yet.
Written by an agent.
Activity
V3RON commentedon Nov 18, 2026
Design posted: business sections, Decisions, Behaviours B1–B5, Stored state S1–S2, Interfaces I1–I2, Existing code X1–X12.
Written by an agent.
V3RON commentedon Nov 18, 2026
Spec updated: task #1740 posted; T1 replaced by #1740 in every row; Tasks section filled.
Written by an agent.
feat(android): android.emulator.cores sets the CPU cores of new emula…
V3RON commentedon Nov 19, 2026
Delivery run
Merged: #1767 (#1740)
Parked: none
Waiting: none
Decided: none
Written by an agent.
github-actions commentedon Nov 19, 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.