Repository navigation
Description
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.tswebsite/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.coresis 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.coresjoins the launch settings.src/drivers/android/AGENTS.md"Boot": copies boot fromsimlock_bootwith-no-snapshot-save; no-coresflag is added (X7).src/contract/AGENTS.md:config.getcarries 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:2and1written;0,-1,2.5,abcrefused with the message, exit 2, nothing written; a config file with"2"ortruerefused at load; unset loads with nocores - B2: a new seed's
config.iniholdshw.cpu.ncore=<cores>before its first boot: built-in profile withcores: 2→ 2; SDK profile → 2; devices.xml profile → 2; built-in profile withcoresunset → 4 - B3: a seed or baseline made under another
coresvalue is stale: unset/unset not stale;headless: truewithcoresunset 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 prints2foradb shell nprocand its daemon log has noAndroid snapshot boot fell back to a cold bootline for it; a device leased beforeenv.withConfig({ android: { emulator: { cores: 2 } } }, …), saved as a baseline inside it, gives a lease that prints2with 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
coresinto the copy before its snapshot boot: made at 4, saved withcores: 2→ 2 and not stale; made at 2, saved with 2 → 2; made at 2, saved withcoresunset → 2
Done when
pnpm test:changedpasses, with the B1, B2, B3 and B6 cases above.pnpm typecheckandpnpm lintpass.- 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.mdxlistsandroid.emulator.coresand its note says only new devices get it;website/src/content/docs/docs/worker/configuration.mdxhas 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
test: an owner sets android.emulator.cores to a positive integer (#1740)
feat(android): android.emulator.cores is a config key taking a positi…
test: a seed made under another android.emulator.cores is stale (#1740)
feat(android): a seed made under another android.emulator.cores is st…
test: a baseline save writes the current android.emulator.cores into …
feat(android): a baseline save writes the current android.emulator.co…
test: a baseline made under another android.emulator.cores is stale a…
docs(android): android.emulator.cores in the configuration pages, the…
docs(android): shorten the cores line of the driver manual (#1740)
chore(android): merge origin/main into the cores branch (#1740)
docs(android): the Android manual fits its size cap after the merge (#…
docs(config): the cores note says what happens to old devices, seeds …
test(android): the cores lane test stops its first daemon before the …
feat(android): android.emulator.cores sets the CPU cores of new emula…