test(sidebar): the rebuild check waits on turns and the list's state, not fixed sleeps (47 s to 7 s, 122 s to 30 s)

Merged
LA
5d ago
+25-2

Summary

SidebarIncrementalMatchesRebuildTests.expectMatchesRebuild (also used by SidebarIncrementalMatchesRebuildGapsTests) spent most of both suites' time in two fixed waits:

  1. Three 30 ms sleeps to let the list's completions run. On a fleet mini they took 90 to 440 ms per check.
  2. for _ in 0..<200 where <differs or animates or fades> { sleep 50 ms }. A for … where loop does not stop at the first match: it sleeps only while the list differs, but it looks 200 times. Nothing on the main thread changes between two looks with no await between them, so the 199 looks after a match were waste: 100 to 130 ms per check.

Diag job b5651a8eb364 (cmux7s, 329 checks): these two waits were 37 of 45 s in the base suite and 100 of 122 s in the Gaps suite.

Change (test-only, one file):

  • The completions run in three main-thread turns (turn): a yield for queued main-actor work, a run-loop pass that does not wait, then the window's layout, display and Core Animation commit (this runs the completion blocks of changes that did not animate).
  • The wait is a while loop with the same 50 ms sleep, the same three conditions (equal to the rebuild, no layer animation, no fading row) and the same 10 s cap. It ends at the first look that matches.

Every operation, check and compared field stays the same. In diag job 183c33f81446 (cmux10s), 46 of 223 checks still had to sleep (springs and fades with motion on), and the loop still waits for them.

Owner: a590 (sidebar-owner agent, plans/cmux-next/sidebar-owner.md). No CmuxNextSidebar source changes, so no Sidebar-Look trailer.

Performance

Suite time (✔ Suite X passed after N seconds):

suitehostbase e96e37a96fbhead e35bab83813
SidebarIncrementalMatchesRebuildTestscmux14, each job alone47.4 s (job 51af475dc4be)6.7 s (job 40dbb4035de2)
SidebarIncrementalMatchesRebuildGapsTestscmux14, each job alone122.0 s (same job)29.9 s (same job)
bothbase8 shards at 61ad0ed216f (loaded hosts)143.8 s / 130.2 s

Other runs at the head: cmux10s 5.8 s / 29.5 s (98a24281f3fb), diag 183c33f81446 on cmux10s 29.2 s for the Gaps suite.

Under load the Gaps suite is still slow at both ends, and this PR does not fix that:

  • cmux10s with a second job on the host: the base Gaps suite hung (theListMatchesAFreshRebuild(_:) made no progress for 180s, job 80bb54a3d540).
  • cmux12s, base and head jobs at the same time: base 433.7 s (c446ecbf2264), head 357.3 s (bb45546d4a71).
  • cmux14 while another job compiled: head 297.2 s (2795363c62ff).
    I did not find where that time goes: the diag runs were on quiet hosts. The base suite (reduce motion, no NSEvent path) stays at 6.5 to 6.8 s under the same load.

Testing

cmux-ci run --class light --display --target-worker <host> --script scripts/ci/package-test-lane.sh --ref <sha> --arg=suite --arg=Packages/macOS/CmuxNext --arg=SidebarIncrementalMatchesRebuildTests,SidebarIncrementalMatchesRebuildGapsTests --env CMUX_TEST_REQUIRE_GUI=1 --env CMUX_CI_XCODE_APP=/Applications/Xcode_26.6.app: all 25 cases pass at the head.

Observed / Not run

  • Observed: both suites pass at the head on cmux14 (40dbb4035de2, 2795363c62ff), cmux12s (bb45546d4a71) and cmux10s (98a24281f3fb). Phase timings from the diag branches speed-sidebar-diag and speed-sidebar-diag3 (not for merge).
  • Not run: the full CmuxNextAppTests target.

Changelog

none


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


Summary by cubic

Speeds up the sidebar rebuild test helper by waiting on main-thread turns and the list's state instead of fixed sleeps.

SidebarIncrementalMatchesRebuildTests.expectMatchesRebuild now runs the completions in three main-thread turns (a yield, a non-blocking run-loop pass, then layout, display and commit) instead of three 30 ms sleeps, and the match wait is a while loop with the same conditions and 10 s cap that stops at the first match instead of a for … where loop that kept looking 199 times. All checks, operations and compared fields are unchanged; all 25 cases pass. Suite time drops from 47 s to 7 s (SidebarIncrementalMatchesRebuildTests) and 122 s to 30 s (SidebarIncrementalMatchesRebuildGapsTests). Under load the Gaps suite is still slow, but fixing that is out of scope here.