Skip to content

Android: android.emulator.cores sets the cores of new emulators and baselines #1740

Closed

Description

@V3RON

Part of #1737.

Scope

A worker owner sets android.emulator.cores and every Android emulator the worker makes from then on, from a seed or from a baseline saved after the change, runs with that many cores and still boots from its snapshot. With the key unset, nothing changes and no seed is made again.

If this goes wrong, a user would see either emulators that still have 4 cores with no error, or every Android lease cold-booting (slow) after an upgrade.

Technical spec

Commit c1130b8.

Rows

  • Behaviours: B1, B2, B3, B4, B5, B6
  • Stored state: S1, S2
  • Interfaces: I1, I2, I3
  • Existing code: X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15

Facts

# Fact Source
F1 A fallen-back snapshot boot is logged at warn as Android snapshot boot fell back to a cold boot with deviceId and readyAfterMs src/daemon/driver-discovery.ts:250-255
F2 The driver flags a fallen-back snapshot boot only when ready took over three times SNAPSHOT_BOOT_ESTIMATE_MS src/drivers/android/emulator.ts:305-311
F3 A slow e2e flow can change config.json keys and restart its daemon mid-test with env.withConfig(overrides, fn) e2e/helpers/env.ts:188-190
F4 The driver test harness starts a second driver over the same database, standing for the daemon after a restart, and takes emulator launch options src/drivers/android/test-driver-harness.ts:82,137-138
F5 Today simlock config set android.emulator.cores 2 is refused as an unknown key with exit 2 USAGE src/drivers/android/definition.ts:52-57 (no cores validator), src/core/validation.ts:40-42, src/cli/index-device-config.test.ts:318-322

Modules touched

Searches: AndroidEmulatorLaunchOptions, seedLaunchInputs, AvdConfigOptions, applyLibraryProfile, saveSource, hw.cpu.ncore, android.emulator in src, e2e and website/src/content/docs.

  • src/drivers/android/ (definition.ts, index.ts, avd-config.ts, seeds.ts, their tests)
  • src/cli/ (test only: index-device-config.test.ts)
  • e2e/slow-android-smoke.test.ts
  • website/src/content/docs/docs/reference/configuration.mdx, website/src/content/docs/docs/worker/configuration.mdx

Rules in play

  • src/drivers/AGENTS.md "Opaque to core": android.emulator.cores is a key the driver's definition file declares; core carries it unread.
  • src/drivers/android/AGENTS.md "Seeds and copies" (ADR 0061): a seed whose launch settings changed is stale and made again; a stale baseline is refused, never copied. cores joins the launch settings.
  • src/drivers/android/AGENTS.md "Boot": copies boot from simlock_boot with -no-snapshot-save; no -cores flag is added (X7).
  • src/contract/AGENTS.md: config.get carries a driver's own keys as sent, so no protocol bump (X12).
  • Documentation rule 9: the configuration pages change in the same PR (B5).

Tests

The seam is the Android driver through src/drivers/android/test-driver-harness.ts (model: src/drivers/android/index-image-fit.test.ts), the CLI through runCli with the real config loader (model: src/cli/index-device-config.test.ts:342-370), and one slow flow in e2e/slow-android-smoke.test.ts.

  • B1: an owner sets android.emulator.cores: 2 and 1 written; 0, -1, 2.5, abc refused with the message, exit 2, nothing written; a config file with "2" or true refused at load; unset loads with no cores
  • B2: a new seed's config.ini holds hw.cpu.ncore=<cores> before its first boot: built-in profile with cores: 2 → 2; SDK profile → 2; devices.xml profile → 2; built-in profile with cores unset → 4
  • B3: a seed or baseline made under another cores value is stale: unset/unset not stale; headless: true with cores unset not stale and its fingerprint equal to today's; unset → 2 stale; 2 → 2 not stale; 2 → 3 stale; 2 → unset stale; baseline made unset, now 2 → listed stale and its provision refused
  • B4: on the slow lane, with cores: 2, a Pixel 9 lease prints 2 for adb shell nproc and its daemon log has no Android snapshot boot fell back to a cold boot line for it; a device leased before env.withConfig({ android: { emulator: { cores: 2 } } }, …), saved as a baseline inside it, gives a lease that prints 2 with no such line
  • B5: the configuration reference row, the note under it, and the worker configuration task row
  • B6: a baseline save writes the current cores into the copy before its snapshot boot: made at 4, saved with cores: 2 → 2 and not stale; made at 2, saved with 2 → 2; made at 2, saved with cores unset → 2

Done when

  • pnpm test:changed passes, with the B1, B2, B3 and B6 cases above.
  • pnpm typecheck and pnpm lint pass.
  • Slow lane: scripts/slow-e2e.sh e2e/slow-android-smoke.test.ts -t "android.emulator.cores" passes (B4).
  • website/src/content/docs/docs/reference/configuration.mdx lists android.emulator.cores and its note says only new devices get it; website/src/content/docs/docs/worker/configuration.mdx has the task row.

Out of scope

The feature's Non-goals: per-lease or per-profile cores, RAM, a doctor check, the post-boot CPU, changing existing devices, a total CPU cap.

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 18, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 18, 2026
  3. self-assigned this
    on Nov 19, 2026
  4. added a commit that references this issue on Nov 20, 2026
    f0339a9
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