Skip to content

Cap Metro maxWorkers to leave host cores free for the device under test#152

Merged
V3RON merged 7 commits into
mainfrom
perf/metro-worker-cap
Jul 11, 2026
Merged

Cap Metro maxWorkers to leave host cores free for the device under test#152
V3RON merged 7 commits into
mainfrom
perf/metro-worker-cap

Conversation

@V3RON

@V3RON V3RON commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

User impact

Harness test runs stay more responsive by balancing Metro work with the device under test, reducing slowdowns on larger development machines. Small CI runners behave as before.

Depends on #151; retarget to main after it merges.

…able

GitHub-hosted runners only have 2-4 cores, so an emulator claiming a
device-profile default of 4 vCPUs oversubscribes the host alongside Metro
and the Node test session during startup. Bake a fixed hw.cpu.ncore=2 into
each AVD's config.ini (fixed, not host-derived, so snapshots stay portable
across runner sizes), regenerate incompatible cached AVDs, roll the AVD
cache key so old caches are replaced once, and add a non-fatal warning when
KVM/HVF acceleration looks unavailable.
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-harness Ready Ready Preview, Comment Jul 11, 2026 5:43pm

Request Review

V3RON added 2 commits July 11, 2026 19:22
…ed action

Now that the action has a real dependency on platform-android for
EMULATOR_CPU_CORES, drop the local copy of getHostAndroidSystemImageArch
and import the original, which is behaviorally identical. The local
resolveAvdCachingEnabled stays: it is intentionally simpler than the
platform-android variant, which also gates on interactivity.
Share a 2-4 core guest allocation between Android AVD creation, compatibility checks, action cache keys, and Metro consumers. This preserves CI behavior while allowing larger development hosts to use four emulator vCPUs.
@V3RON V3RON force-pushed the perf/metro-worker-cap branch from 3bb0943 to cfe7934 Compare July 11, 2026 17:39
@V3RON V3RON changed the base branch from main to perf/emulator-cpu-cores July 11, 2026 17:39
V3RON added 4 commits July 11, 2026 19:43
Describe the user-visible benefit of adaptive emulator CPU allocation.
GitHub-hosted CI runners are small (2-4 cores), and Metro's default
maxWorkers formula can claim every host core for transform workers. The
Android emulator is now pinned to 2 vCPUs and the iOS simulator runs as
host processes, so leaving no headroom starves the device right when both
are busiest, at startup. Reserve 2 host cores for the device and only ever
lower Metro's resolved maxWorkers to respect that, never raise it.

Also fixes a pre-existing @nx/dependency-checks lint failure in this
package (missing "vite" from ignoredDependencies, unlike every sibling
package's eslint config) that was blocking commits here.
Use the shared host-derived guest allocation so Metro reserves exactly the cores granted to the emulator. This retains 2-core CI behavior and restores a 4-core emulator budget on 8-core hosts.
Describe the user-visible startup responsiveness benefit.
@V3RON V3RON force-pushed the perf/metro-worker-cap branch from cfe7934 to 3237156 Compare July 11, 2026 17:43
Base automatically changed from perf/emulator-cpu-cores to main July 11, 2026 17:45
@V3RON V3RON merged commit b4d538a into main Jul 11, 2026
2 checks passed
@V3RON V3RON deleted the perf/metro-worker-cap branch July 11, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant