Skip to content

test(zero-swift): time the main thread and count layouts in TestHost's frame probe - #274

Merged
tmm merged 1 commit into
mainfrom
swift-testhost-probe-timing
Nov 20, 2026
Merged

tmm merged 1 commit into
mainfrom
swift-testhost-probe-timing

Conversation

@tmm

@tmm tmm commented Nov 20, 2026

Copy link
Copy Markdown
Member

The TestHost frame probe checks rows' positions and blank space but not what a frame costs, which the last perf check listed as missing ("layouts per frame and frame time in TestHost"). From the first phase after open, the probe's summary now also reports:

  • busyms: the main thread's busy time per display frame, measured with a run loop observer from wake to the next wait
  • stalls=N120/N60 and stallms: how many busy spans ran over 8.3 ms and over 16.7 ms, and the total time of the spans over 8.3 ms
  • layouts, with -probe-layouts 1: layouts of SwiftUI's hosting views (the rows' and the list's) per frame the list moved, counted by hooking their layout / layoutSubviews

Example, macOS, issue list with SwiftUI rows, -probe-script blanking -latency 50:

DONE wrong=41 frames=6762 moving=5141 dropped=8 blank=0 busyms=2.67 stalls=456/51 stallms=5791 done

The new fields come before last=[…], so FrameProbeUITests' parsing of wrong=, phases=[…], flings=[…] and the done suffix doesn't change. Counting layouts costs time itself: about 1.5 ms per frame on macOS in blanking (4.27 vs 2.69 ms busy). So busyms should only be compared between runs with the same flags, as the doc comment now says.

These are the numbers behind #273, which cut macOS busy time per frame by 15–30%.

Run locally. Built and run in Release for macOS and the iOS Simulator (Xcode 27.3) with the issues, blanking and chat scripts. swift format lint --strict.

No changeset: TestHost only.

…s frame probe

The frame probe checked positions and blank space but not what a frame
cost, which the last perf check listed as missing. From the first phase
after `open`, its summary now also has:

- `busyms`: the main thread's busy time (run loop wake to wait) per
  display frame
- `stalls=N120/N60` and `stallms`: busy spans over 8.3 and 16.7 ms, and
  their total
- `layouts` (with `-probe-layouts 1`): layouts of SwiftUI's hosting views
  per frame the list moved, by hooking their `layout`/`layoutSubviews`

The new fields come before `last=[…]`, so the UI tests' parsing of
`wrong=`, `phases=`, `flings=` and the ` done` suffix is unchanged.
Counting layouts costs about 1.5 ms per frame on macOS in `blanking`, so
`busyms` compares only between runs with the same flags.

Amp-Thread-ID: https://ampcode.com/threads/T-884aab88-be49-4bc7-96a1-044f0e71dabf
Co-authored-by: tmm <tmm@tmm.dev>
@tmm
tmm merged commit 1d67ff0 into main Nov 20, 2026
36 of 37 checks passed
@tmm
tmm deleted the swift-testhost-probe-timing branch November 20, 2026 23:52
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.

2 participants