ci: merge queue 吞吐——Test Core/Dogfood 各 3 分片 + 队列失败自动分诊评论 - #4863
Merged
Conversation
2026-08-03 上午实测:队列构建关键路径 ~11 min(Test Core 慢分片 9m50s),
且 20 个队列构建 7 个失败,失败被盲目重排、每次连坐重建后面所有构建——
失败放大才是队列慢的主因,构建时长是次因。
- Test Core 2→3 分片:慢分片 ~10min → 预期 ~5-6min。required 上下文由
test-gate 聚合层承载("Test Core"),分片数可变正是它存在的目的(#3622)。
- Dogfood 2→3 分片:Test Core 砍掉后的新长杆(7m38s → 预期 ~5min)。顺带
给其 turbo restore 补 job 级 catch-all 恢复键(Test Core 已有同款),
新分片号在 main 播种前不至于全冷。
- 新增 merge-queue-triage.yml:merge_group 的 CI 失败 → 自动在 PR 上评论
失败 job/测试行 + 本 PR 24h 重排失败史 + 队列失败面板 + 分诊清单,
给人和 PM agent「先诊断再重排」的机器可读信号。cancelled(连坐撤销)
不触发。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNH5jsbfeRTZPwBmBbkwMH
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNH5jsbfeRTZPwBmBbkwMH
Contributor
Author
CI 全绿(21/21,head
|
| Job | 实测(本 PR 运行) | 说明 |
|---|---|---|
| Test Core (1/3 / 2/3 / 3/3) | 1m12s / 1m00s / 49s | 不代表队列:PR 侧走 --affected,workflow-only diff 几乎没有包可测。队列跑全量分区,按 2 分片数据推算 ≈ 每片 ~5m50s 测试步 + ~1m20s setup ≈ ~7m10s job |
| Dogfood Gate (1/3 / 2/3 / 3/3) | 6m49s / 6m45s / 6m51s | 全量套件(dogfood 不走 affected),这是真实数字。比预告的 ~5min 高:三片高度一致 ⇒ 每分片固定开销(setup + turbo 回放 + 每文件 app 启动)占比大,2→3 分片只省了 ~40s job 时长 |
| 聚合 gate(Test Core / Dogfood Regression Gate) | 均正常发布裸名上下文 | branch protection 契约未动,验收 ✓ |
诚实修正一条预期:Dogfood 的分片收益递减明显(总 CPU 时间反而增加 ~4min,因为固定开销 ×3),3 分片是拐点,不要再加。队列关键路径预期修正为 max(Test Core ~7m10s+gate, Dogfood ~6m50s+gate) ≈ ~7m30s,仍在承诺的 7-8min 区间,对比现状 ~11min。
最终验证是本 PR 自己的 merge_group 构建——现在把它送进队列,队列运行的分片时长会是第一份全量 3 分片样本,落地后回帖收尾。
Generated by Claude Code
Contributor
Author
收尾:merge_group 全量 3 分片实测(run 30810379184,本 PR 自己的队列构建)队列构建端到端:7m10s(11:39:15 → 11:46:25),基线 ~11min,-35%。
两条如实说明:
遗留给维护者的最后一件(代码够不着):Settings → Rules 的 merge queue 并发建议 ≥5,flaky 清掉前每组 PR 保持 1-2。 Generated by Claude Code |
This was referenced Aug 3, 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.
Fixes #4859
背景(2026-08-03 上午全量 merge_group 运行实测)
队列体感慢,查证结论:失败放大是主因,构建时长是次因。
filter(10s) → Test Core (2/2) 测试步 9m50s → 聚合 gate。分片按文件数均分但时长不均(9m50s vs 7m47s)。改了什么
1. Test Core 2→3 分片(
ci.yml):matrix[1,2,3]+ 分区参数/3,慢分片 ~10min → 预期 ~5-6min。安全性:branch protection 只 require 聚合 gate 的裸名Test Core,gate 承载稳定名正是为了让分片数可变(#3622 教训);分片矩阵名不在 required 列表。2. Dogfood 2→3 分片(
ci.yml):Test Core 砍掉后的新长杆(7m38s → 预期 ~5min)。vitest 文件级分片对单包 ~60 文件安全。顺带给其 turbo restore 补上 job 级 catch-all 恢复键(Test Core 已有同款、dogfood 缺)——新分片号在 main 首次播种前不至于全冷。同步修正了 job 头注释里「branch protection 须改成两个分片名」的过时说法(与 dogfood-gate 的实际契约相反)。3. 新增
merge-queue-triage.yml:workflow_run(CI, completed) 且event == merge_group && conclusion == failure时,解析队列分支名取 PR 号,自动评论:失败 job/步骤 + 日志抽取的失败测试行(best effort)+ 本 PR 24h 内队列失败次数 + 队列面板 + 分诊清单(改动包内→修 PR;无关→跨 PR 搜同名测试定 flaky,修好前别重排;组合冲突→等前面出队再排)。cancelled(连坐撤销/手动取消)不触发,与 dogfood-gate 对 cancelled 的语义一致。幂等(按 run id 去重)、最小权限(actions: read+pull-requests: write)、不 checkout 任何 PR 代码。预期效果:队列构建关键路径 ~11 min → ~7-8 min;重排前有诊断信号,减少「一个 flaky 烧整条队列」的循环。
没改的(供维护者操作)
merge queue 本身的设置在 Settings → Rules,代码够不着:建议并发投机构建 ≥5;flaky 清理干净之前每组 PR 数保持小(1-2)。
验证
grep无残留/2分片引用;node scripts/partition-test-shards.mjs --self-test通过(分区脚本本身对 N/M 泛化,LPT 贪心不依赖分片数);ci.yml,按 filter 规则会全量跑,正好是第一份 3 分片样本。无 changeset:仅
.github/workflows/**,不触任何发布包。🤖 Generated with Claude Code
https://claude.ai/code/session_01YNH5jsbfeRTZPwBmBbkwMH
Generated by Claude Code