Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ there, and unmanaged labels are never simslim's business), the booted device is
always read back with `print-disabled` rather than trusted, and anything that
does not work out returns `errOfflineIneffective` so `ensure` falls back to the
`launchctl` path. A store problem must never surface as a command failure.
`watch.go` uses the same store to slim a shut-down device before it boots
(`preslimDevice`): it only adds the profile's disables, to every shut-down
device on startup. A kqueue `NOTE_WRITE` watch on each device-set directory
(`watch_dirs_darwin.go`, re-attached each scan interval while a set directory is
missing) seeds a new device from its `device.plist` in its own goroutine
(`seedNew`), since a `simctl list` on a loaded host takes longer than a script
waits between `simctl create` and boot. A boot that starts first is logged and
caught by the no-reboot slim at boot, which stays as the read-back and fallback.

**Live enable/disable.** `live.go` holds `EnableServices`/`DisableServices`
(`simslim enable`/`disable`), which act on a booted simulator only and keep no
Expand Down
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,33 @@ simslim enable <udid> icloud --save dev.json # on now, and in dev.json
simslim watch --profile dev.json # keeps iCloud on at every boot
```

### Slimming parallel-testing clones

`xcodebuild` parallel testing creates a fresh clone per worker in its own device
set, runs the tests, and deletes the clones when the run ends. The clones are
created stock, and disable overrides do not survive `simctl clone`, so there is
no device to slim ahead of time. `simslim watch` closes that gap: it polls the
device sets and slims each simulator no-reboot the moment it boots, then leaves
it alone until it boots again. A clone slimmed a few seconds into a multi-minute
### Slimming every new simulator, from its first boot

`simslim watch` keeps every simulator slim without a command per device. A
simulator that is shut down, on a runtime that persists overrides (iOS/tvOS
18.5, watchOS 11.5, visionOS 2.5 or newer), is slimmed before it boots: watch
writes the profile's disable overrides into its launchd store, so its next boot
starts none of those daemons. That includes a simulator's very first boot:
watch follows the device-set directories with kqueue and seeds a new device from
its own `device.plist` within milliseconds of `simctl create`, without waiting
for `simctl list`. A boot that starts before the seed lands is slimmed as it
boots instead, and comes up slim from its next boot. A script that creates and
boots a simulator should not race watch: run
`simslim on <udid> --preserve-boot-state` between `simctl create` and the boot,
which slims the device and leaves it shut down.
Watch only ever adds disables there, as it does after boot: a service disabled
beyond the profile stays disabled until `simslim off`.

This changes what watch does on startup: it now writes the slim profile into
every shut-down simulator in the watched sets, not only the ones that boot while
it runs. Run `simslim off <udid>` to bring one back to stock.

Every simulator is also slimmed no-reboot the moment it boots, which reads the
device back and covers whatever booted before watch could seed it. That is the
only hook for `xcodebuild` parallel-testing clones: parallel testing creates a
fresh clone per worker in its own device set, runs the tests, and deletes the
clones when the run ends. The clones are created stock, and disable overrides do
not survive `simctl clone`. A clone slimmed a few seconds into a multi-minute
run keeps its freed memory for the rest of the run. A failed slim is retried on
the next scan, and a device that shut down and booted again is slimmed again,
because on older runtimes a no-reboot slim ends with the boot session.
Expand Down
18 changes: 11 additions & 7 deletions cmd/simslim/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,19 @@ func onNoReboot(ctx context.Context, device simslim.Device, p simslim.Profile, r
return nil
}

// cmdWatch slims every simulator no-reboot as it boots, until Ctrl-C. It is the
// hook for xcodebuild parallel-testing clones, which are created stock and
// deleted per run: point --set at the parallel-testing device set and run this
// alongside the test invocation.
// cmdWatch slims every simulator until Ctrl-C: a shut-down one before it boots,
// by writing its launchd overrides, and every one no-reboot as it boots. It is
// also the hook for xcodebuild parallel-testing clones, which are created stock
// and deleted per run: point --set at the parallel-testing device set and run
// this alongside the test invocation.
func cmdWatch(ctx context.Context, cmd *cli.Command) error {
p, err := simslim.BuildProfile(cmd.String("profile"), cmd.String("except"), cmd.String("keep"))
if err != nil {
return err
}
report := simslim.Reporter(func(msg string) { fmt.Fprintln(os.Stderr, msg) })
sets := append([]string{"default", "testing"}, simslim.ExtraDeviceSetTokens()...)
fmt.Fprintf(os.Stderr, "Watching device sets [%s]; slimming each simulator no-reboot as it boots. Ctrl-C to stop.\n", strings.Join(sets, ", "))
fmt.Fprintf(os.Stderr, "Watching device sets [%s]; slimming each simulator before it boots where its runtime allows, and no-reboot as it boots. Ctrl-C to stop.\n", strings.Join(sets, ", "))
return simslim.Watch(ctx, p, cmd.Duration("interval"), report)
}

Expand Down Expand Up @@ -1098,8 +1099,11 @@ COMMANDS
that is fully enabled keeps running. To go back to a
profile, run ` + "`on <udid> --no-reboot --profile path`" + `
--save path Also remove them from this profile file
watch Slim every simulator no-reboot as it boots, until Ctrl-C.
The hook for xcodebuild parallel-testing clones, which are
watch Slim every simulator until Ctrl-C: a shut-down one before
it boots (iOS/tvOS 18.5+, watchOS 11.5+, visionOS 2.5+),
so even its first boot starts none of the profile's
daemons, and every one no-reboot as it boots. The hook
for xcodebuild parallel-testing clones, which are
created stock and deleted per run; point --set at the
parallel-testing device set
--profile path Apply a committed JSON profile (see below); mutually
Expand Down
Loading
Loading