Optimize reboots with Android emulator initialization#5280
Open
jardondiego wants to merge 14 commits into
Open
Optimize reboots with Android emulator initialization#5280jardondiego wants to merge 14 commits into
jardondiego wants to merge 14 commits into
Conversation
IvanBM18
reviewed
May 18, 2026
IvanBM18
reviewed
May 18, 2026
IvanBM18
reviewed
May 18, 2026
fernandofloresg
approved these changes
May 18, 2026
Collaborator
fernandofloresg
left a comment
There was a problem hiding this comment.
lgtm, would be nice to add those docstrings
letitz
requested changes
May 19, 2026
Collaborator
letitz
left a comment
There was a problem hiding this comment.
I'm a bit confused about the main logic change in initialize_device(), see comment below.
added 14 commits
May 21, 2026 01:32
This change reduces the number of reboots during Android device setup by: - Adding a wait_for_reboot parameter to adb.write_data_to_file. - Tracking reboot status in initialize_device to skip the final reboot if one already occurred. - Disabling reboots when setting sanitizer options since the app restart is sufficient. These optimizations improve bot startup efficiency and overall fuzzing throughput.
… tracking and short-circuit issues
Adds `-> bool` return type hints and explanatory docstrings to: - `configure_system_build_properties` - `setup_asan_if_needed` These updates clarify that the returned boolean indicates whether a device reboot occurred during the setup step.
- Revert configure_system_build_properties to not return a bool. - Simplify initialize_device to only reboot if ASan setup did not reboot the device. This fixes the bug where it would reboot even if no properties changed. - Refactor device_test.py to use helpers.patch instead of manual mock setups, matching the codebase style.
bff881e to
2888eab
Compare
letitz
reviewed
May 21, 2026
Collaborator
letitz
left a comment
There was a problem hiding this comment.
One substantive comment around skipping reboots after writing ASan options, otherwise just two small nits.
Comment on lines
+889
to
+890
| should_reboot: Whether to reboot the device if a system file is modified. | ||
| Defaults to True. |
Collaborator
There was a problem hiding this comment.
Let's explain what a system file is, and no need to repeat the default argument value since that's self-documenting:
Suggested change
| should_reboot: Whether to reboot the device if a system file is modified. | |
| Defaults to True. | |
| should_reboot: Whether to reboot the device after writing the file. | |
| Only applies if `file_path` is under `/system`, since we need to | |
| remount that partition as read-write first. |
| """Tests the reboot batching logic in initialize_device.""" | ||
|
|
||
| def setUp(self): | ||
| from clusterfuzz._internal.tests.test_libs import helpers |
Collaborator
There was a problem hiding this comment.
Let's move this to the top level, no need to make this import conditional on the test being run?
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.
Goal
Significantly improve the startup efficiency and fuzzing throughput of Android bots by eliminating redundant, time-consuming device reboots during the initialization and sanitizer setup phases.
Background
Historically, Android bots suffered from excessive hard reboots (~60s penalty each) during task execution: