perf: enable Android emulator Quick Boot - #359
Draft
janicduplessis wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Owned Android AVDs cold-boot on every restart because Stim disables both Quick Boot loading and saving, adding about 22 seconds in the measurements from #284.
The flags were added in PR #93 to reduce AVD storage (commit lines), before Stim measured and configured owned-AVD userdata. This PR depends on #357 because Quick Boot saves state during graceful shutdown; the guest-write flush must merge first.
Solution
Use Android Emulator's default Quick Boot policy for owned AVDs except on displayless Linux, where Stim's required software renderer is incompatible with snapshots. A new AVD or an invalid snapshot cold-boots; later supported restarts load the single automatic snapshot saved on exit. Android invalidates snapshots after emulator, system-image, or AVD-setting changes (Android snapshot documentation).
adb emu killreturns before emulator shutdown necessarily finishes. Teardown now reads the exact emulator PID from the owned AVD's active process lock before sending the shutdown request, then waits up to 60 seconds for both the bounded adb command and that process to exit. Emulator process exit occurs after the Quick Boot save. Offline emulators are resolved through their console identity; an ADB-invisible live process, a timeout, or an AVD relaunched before deletion keeps the ownership record and prevents deletion.New owned AVDs default to an 8 GiB data partition, project settings can choose another size, and existing AVDs keep their configured size. When enabled, Quick Boot keeps one automatic snapshot;
stim worktree removedeletes the whole AVD, andstim gcreports the size of stale or orphaned owned AVDs. The benchmark control prompt now uses the same policy.Test plan
-avd stim-issue-284-verification -port 5580and failed only because that deliberately nonexistent AVD was absent; no installed device was touched.Fixes #284.