Skip to content

Fix the composer clearing test timeout on busy CI runners - #1173

Merged
onevcat merged 1 commit into
mainfrom
fix/composer-clearing-test-starvation
Nov 23, 2026
Merged

onevcat merged 1 commit into
mainfrom
fix/composer-clearing-test-starvation

Conversation

@onevcat

@onevcat onevcat commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Summary

AgentComposerClearingTests/killLinesStopsAtTheFirstEmptyReadingAndCapsPresses() hit its one-minute time limit in 5 of the last 7 failed test runs (for example run 45141949753). The fix in 616d312 did not stop it.

Root cause: TestClock.advance runs Task.megaYield twice per tick. Each megaYield starts 20 detached .background-priority tasks. On a busy runner those tasks starve. The capped case steps the clock through up to 80 settle polls, which is thousands of such tasks.

Fix: the executor counts settle polls, not time. The tests now inject YieldingClock (new, in TestWaiting.swift), whose sleep is one Task.yield(). The typing test injects the local key at the first settle poll through onObserve, as aLocalKeyCoincidingWithTheEmptyReadingRefuses already does. TestClock is no longer used in this file. The advance(_:by:until:) doc now warns about the megaYield cost.

Verification

  • Repro: with all cores busy (yes × 2 × ncpu), the test failed locally at 60 s. With TASK_MEGA_YIELD_COUNT=0 it passed in 5 ms. This confirms the starvation.
  • After the change: AgentComposerClearingTests (8 tests) passed 3 times in a row under the same load; the slowest test took 4 ms.
  • make check and the full make test pass.

TestClock.advance runs Task.megaYield twice per tick, and each megaYield
starts 20 detached background-priority tasks. On a busy CI runner those
tasks starve. The capped kill-lines case steps the clock through up to 80
settle polls, so it hit the one-minute time limit (5 of the last 7 failed
test runs). Under full CPU load it fails locally too; with
TASK_MEGA_YIELD_COUNT=0 it passes in 5 ms.

The executor counts settle polls, not time, so inject YieldingClock, whose
sleep is one Task.yield. The typing test now injects the local key at the
first settle poll through onObserve instead of advancing a TestClock.
@onevcat
onevcat merged commit 54df3ce into main Nov 23, 2026
2 checks passed
@onevcat
onevcat deleted the fix/composer-clearing-test-starvation branch November 23, 2026 12:05
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.

1 participant