Repository navigation
feat: slim new simulators before their first boot - #65
Conversation
watch now writes the profile's disable overrides into a shut-down simulator's launchd store, so its next boot, its very first included, starts none of those daemons. It lists the device-set directories every 50ms and seeds a new simulator from its device.plist, without waiting for a simctl list, which on a loaded host takes longer than a script waits between create and boot. It only adds disables, like the no-reboot slim at boot, which stays as the read-back and the fallback for clones, older runtimes and a boot that starts before the seed lands.
|
Awesome! can we get it merged? @sunjinshuai |
Interlap01
left a comment
There was a problem hiding this comment.
Thanks, this is a great addition, and the first-boot numbers are convincing. A few changes before merging:
- Replace the 50 ms directory poll with a
kqueuewatch (EVFILT_VNODE+NOTE_WRITEon each device-set folder, all in Go's standardsyscallpackage, so the library stays dependency-free). The poll keeps waking up 20 times a second for as long aswatchruns.kqueuecosts nothing while idle and notices a new folder in under 1 ms. If a set folder doesn't exist yet (e.g.XCTestDevicesbefore the first parallel-test run), try attaching to it again on each 3s scan. - Handle each new folder in its own goroutine (counted in
wg). Right nowseedNew's 2s wait fordevice.plistblocks the loop that looks for new folders, so a batch of parallel-testing clones gets seeded one at a time. - Remove deleted folders from
known. Otherwise it grows by one entry per clone for the whole session. - Drop the README advice to wait for
/private/var/tmp/.../disabled.plist. It's an internal CoreSimulator path, and the script waits forever ifwatchisn't running, the runtime is older than iOS 18.5, or the profile adds nothing. For scripts, recommendsimslim on <udid> --preserve-boot-statebetweensimctl createand boot instead; that has no race. - Call out the behaviour change in the README: on startup,
watchnow writes the slim profile into every shut-down simulator, not only the ones that boot while it runs.
Replace the 50ms directory poll with a kqueue NOTE_WRITE watch on each device-set directory, re-attached each scan interval while a set directory is missing. Seed each new device in its own goroutine, forget deleted device directories and prune deleted UDIDs from seen and seeded. README: recommend on --preserve-boot-state between simctl create and boot instead of waiting for the store file, and call out that watch now slims every shut-down simulator on startup.
|
@Interlap01 thanks for the review. All five are addressed in 8d26bc6.
Done. Each new folder's
Done. Each
Removed. The README now recommends
Added: on startup,
|
simslim watchslimmed a simulator only after it booted, so every new simulator's first boot started the full daemon set. Scripts and CI that create a fresh simulator per run never got past that first boot, and booting a few at once saturated the Mac.This PR has
watchwrite the profile's disable overrides into a shut-down simulator's launchd store, the same storesimslim onuses, so its first boot already skips those daemons.watchfollows the device-set directories with a kqueue watch and seeds each new simulator from itsdevice.plist, in its own goroutine. It does not wait forsimctl list, which on a loaded host takes longer than a script waits betweensimctl createand boot. A script that boots right after creating should runsimslim on <udid> --preserve-boot-statein between.watchnow writes the profile into every shut-down simulator in the watched sets, not only the ones that boot while it runs.--exceptworks as before.Results
First 90 s after boot, fresh simulator, iOS 26.5 runtime:
com.apple.siri.context.servicestarts on demand, and the slim at boot stops it.assetsd,medialibraryd,photoanalysisd,healthd,STExtractionService,UnityPoster,PosterBoardandsearchdran on stock first boots and not on seeded ones.Tests
make checkpasses. New cases inwatch_test.gocover seeding a shut-down device before boot, retrying a failed seed, adding only disables, leaving other devices alone, finding a new device directory and reading itsdevice.plist, forgetting deleted devices, and attaching to a set directory created later.