Skip to content

perf(ios-runner): settle post-snapshot interactions on a deadline, not a fixed sleep - #5130

Merged
thymikee merged 1 commit into
callstack:mainfrom
imranbarbhuiya:perf/ios-runner-post-snapshot-deadline
Nov 26, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
imranbarbhuiya:perf/ios-runner-post-snapshot-deadline

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2395. After every XCTest snapshot, the runner set mainOwned.needsPostSnapshotInteractionDelay = true, causing applyInteractionStabilizationIfNeeded() to sleep a flat 0.2 s on the next interaction even when seconds had already passed.

Replace the boolean with a monotonic postSnapshotInteractionReadyUptime: TimeInterval? deadline stamped in beginPostSnapshotInteractionStabilization() when the snapshot finishes, mirroring firstInteractionWindow (#2395, #3532). applyInteractionStabilizationIfNeeded() sleeps only readyUptime - ProcessInfo.processInfo.systemUptime and clears the deadline. The guard (from #72) is a minimum gap after the snapshot, so elapsed time satisfies it: tight loops keep the full 200 ms; agent-paced flows credit elapsed round-trip time instead of paying 200 ms twice.

Before / after (iPhone 17 Pro, iOS 27.2 simulator, Settings)

snapshot -i --actions (XCTest path) then fill (350 ms gap, N=7; 0 ms gap, N=5) and back-to-back press (0 ms gap, N=5):

Metric (median, min–max) Base (9d6059c120) Head (21c99f3250) Delta
fill accept→dispatch (350 ms) 204.5 ms (202.3–206.2) 2.6 ms (1.6–10.7) −201.9 ms
fill runner type (350 ms) 2080.3 ms (1999.1–2316.4) 1869.8 ms (1742.1–1938.4) −210.5 ms
fill CLI wall (350 ms) 2322.6 ms (2230.6–2568.2) 2043.8 ms (1903.2–2148.3) −278.8 ms
fill accept→dispatch (0 ms) 205.4 ms (202.8–206.6) 4.1 ms (1.6–53.4) −201.3 ms
press landed (0 ms) 5/5 5/5 —

Validation

  • Tested commit 21c99f3250.
  • Runner XCTest (LifecycleCacheTests + SnapshotExecutionTests, iOS 27.2 simulator): 21 tests, 0 failures.
  • All 5 Apple runner builds (ios, macos, tvos, visionos, watchos) succeeded.
  • pnpm check:affected --base upstream/main --run --head 21c99f3250 (native-dupes, xctest-selection, packaged-runner-swift), pnpm check:quick, and pnpm format:check passed.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

…t a fixed sleep

Replace mainOwned.needsPostSnapshotInteractionDelay with a monotonic
postSnapshotInteractionReadyUptime deadline stamped when an XCTest
snapshot finishes, mirroring firstInteractionWindow (callstack#2395).
applyInteractionStabilizationIfNeeded() now sleeps only the remaining
part of the 200 ms post-snapshot window and clears the deadline.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

Thanks for the contribution, no code problems were found at 21c99f3, and the required evidence is in place. Not verified here: the simulator before/after timings and the runner XCTest result (21 passed, 0 failed) are author-reported and were not re-run, and no physical-device run was done; simulator evidence covers the XCTest behavior this change touches. The only failing checks are two cancelled Body rules runs, superseded by PR body edits. That job checks PR body text and this diff touches only Swift files under apple/runner, so the cancellations are likely unrelated. No code change is needed; before merge, a fresh Body rules run should be confirmed to pass.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee
thymikee merged commit 46a0731 into callstack:main Nov 26, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants