Skip to content

ci: merge queue 吞吐——Test Core/Dogfood 各 3 分片 + 队列失败自动分诊评论 - #4863

Merged
xuyushun441-sys merged 2 commits into
mainfrom
claude/decision-analysis-twjlhg
Aug 3, 2026
Merged

ci: merge queue 吞吐——Test Core/Dogfood 各 3 分片 + 队列失败自动分诊评论#4863
xuyushun441-sys merged 2 commits into
mainfrom
claude/decision-analysis-twjlhg

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Fixes #4859

背景(2026-08-03 上午全量 merge_group 运行实测)

队列体感慢,查证结论:失败放大是主因,构建时长是次因

改了什么

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.ymlworkflow_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 贪心不依赖分片数);
  • 两个 workflow YAML 解析通过;
  • 分片时长与 turbo 缓存命中(新分片号靠 catch-all 键回退)需在本 PR 自己的 CI 运行中观察——本 PR 改了 ci.yml,按 filter 规则会全量跑,正好是第一份 3 分片样本。

无 changeset:仅 .github/workflows/**,不触任何发布包。

🤖 Generated with Claude Code

https://claude.ai/code/session_01YNH5jsbfeRTZPwBmBbkwMH


Generated by Claude Code

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
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 3, 2026 10:37am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling labels Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

CI 全绿(21/21,head cfb7c4e)+ 首份 3 分片实测

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

@xuyushun441-sys
xuyushun441-sys added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit c8ea853 Aug 3, 2026
22 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the claude/decision-analysis-twjlhg branch August 3, 2026 11:46

Copy link
Copy Markdown
Contributor Author

收尾:merge_group 全量 3 分片实测(run 30810379184,本 PR 自己的队列构建)

队列构建端到端:7m10s(11:39:15 → 11:46:25),基线 ~11min,-35%

Job 时长 测试步
Test Core (1/3 / 2/3 / 3/3) 2m18s / 2m16s / 5m00s 1m14s / 1m08s / 4m16s
Dogfood Gate (1/3 / 2/3 / 3/3) 6m42s / 6m44s / 6m48s ~6m05s
Build Core / Docs / Temporal / Console Pin / Verify CLI 1m31s / 2m42s / 2m19s / 1m01s / 1m42s

两条如实说明:

  1. 本次 Test Core 的绝对值偏乐观——workflow-only diff 下大量包的 test 任务被 turbo 缓存回放(这正是队列分支回退到 main 播种键的效果)。碰 spec 的 PR 会更慢,但 3 分片的结构性上界摆在那:最坏也是原 2 分片时长的 ~2/3。分片间不均(1m08 vs 4m16)是缓存命中分布所致,不必按运行时长重新分区,先观察几天。
  2. 新关键路径是 Dogfood(~6m50 + gate)——它的 ~6 分钟是 60 个文件各自启动真实 app 的固定成本,分片收益已到拐点。再想压队列时长,方向是砍 dogfood 单文件启动成本或按时长分区,不是加分片。

merge-queue-triage.yml 已随本次合并进入默认分支,即刻生效:下一个 merge_group 失败会自动收到分诊评论。#4859 由本 PR 关闭。

遗留给维护者的最后一件(代码够不着):Settings → Rules 的 merge queue 并发建议 ≥5,flaky 清掉前每组 PR 保持 1-2。


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd documentation Improvements or additions to documentation size/m tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: merge queue 吞吐优化——Test Core / Dogfood 各 2→3 分片 + 队列失败自动分诊评论

2 participants