Repository navigation
test(codex): 慢启动用例冷启动与固定延迟分开计时,根治偶发超时 - #2892
Merged
Merged
Conversation
现象:slow-launcher 用例在 CI bun-test 上偶发 `timed out waiting for fake Codex startup`, 均停在 15.1s(#2793、#2808、#2809)。 根因:等待假 Codex 就绪的 15s 窗口从 worker 启动起算,里面同时扣了 worker 冷启动(负载相关)和慢启动器固定的 8s 延迟,冷启动实际只剩约 7s,而其它用例的 同一步都有完整 15s。分段计时实测:启动器起来之后完全确定(8008ms 定时 + 约 20ms 拉起 + 约 4ms 就绪),抖动全部在 worker 冷启动(空闲约 0.4s,4 核 8 路并发 + 2 个满载进程下 3.7–14.7s)。 修法:先在独立窗口内等启动器写下自己的启动时刻,再以该时刻为起点给固定延迟 加同样的余量;用例总超时改为由各段窗口推出的关系式,避免外层先超时掩盖是哪一步慢。 验证(isolate-run 4 核,8 路并发 + 2 个满载进程):原代码 50 次失败 9 次,报错与 CI 逐字一致;修复后 slow-launcher 50/50、整文件 16/16 通过。 Closes #2793 Closes #2808 Closes #2809 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 5, 2026 21:13
This was referenced Nov 5, 2026
|
🚀 Released in v3.58.0 |
This was referenced Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
只改
test/worker-codex-lazy-rollout-ownership.integration.test.ts的 slow-launcher 用例夹具,不动src/:launcher-started-at)。40_000改为关系式4 * WAIT_MS + SLOW_LAUNCH_MS(冷启动、延迟余量、history 匹配、回复各一个窗口),避免外层先超时、掩盖是哪一步慢。startupDelayMs分支走新等待)。Closes #2793
Closes #2808
Closes #2809
为什么偶发(根因)
原来「fake Codex startup」的 15s 窗口从 worker 启动起算,里面同时扣了 worker 冷启动(负载相关)和慢启动器 固定 8s 延迟,冷启动只剩约 7s,而同文件其它用例这一步都有完整 15s。
分段计时实测(isolate-run 4 核,8 路并发 + 2 个满载进程,30 次):
抖动全部在 worker 冷启动;启动器之后是确定的。三次 CI 失败日志也是同一形状:worker 在 spawn 启动器后再无输出,15.1s 时超时。
不是「调大超时」:固定延迟和负载相关的冷启动现在各有自己的窗口,冷启动的余量与其它用例一致,不再被固定延迟挤占;固定延迟的计时从启动器自己的时钟算,不受 worker 启动快慢影响。
验证
压力复跑(
isolate-run --cpus 4,每次一个bun test进程,8 路并发 + 2 个 CPU 满载进程):timed out waiting for fake Codex startup,15037–15132ms,与 CI 逐字一致)变异复验:
其它:
bun run build通过;vitest run --project unit test/worker-codex-lazy-rollout-ownership.integration.test.ts test/test-hygiene.test.ts34/34 通过。发现的既有问题(不在本 PR 修)
8s 延迟其实没越过启动器重试循环的实际窗口(每 tick 200ms + 约 160ms 进程扫描,30 次约 10.8s),所以单独摘掉 #2742 新加的任何一处守卫,这条用例都不变红。它钉的是端到端不变量,没钉住单点守卫。变异表与建议记在 #2891。
影响面
仅测试夹具;不涉及生产代码、配置、其它 CLI 或后端。
🤖 Generated with Claude Code