Skip to content

ci: reuse prebuilt embedded race binaries - #29167

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/ut-race-prebuilt-execution
Sep 20, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/ut-race-prebuilt-execution

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement
  • Test and CI

Which issue(s) this PR relates to

Related to #28419 (UT producer cost). Follow-up to merged #29157.

Why

Recent successful race jobs vary from about 34 minutes to 52–57 minutes. The slowdown is broad across stages and correlates with roughly 2x CPU work plus materially higher CPU/I/O pressure, rather than cluster-admission waiting alone. In the latest #29157 run, embedded packages still occupied about 17m54s of the serial critical path.

The embedded group currently contains nine race packages after the exclusive pkg/tests/issues package is removed. Each package has a large compile/link cost. The old optional prebuild only warmed the Go cache, deleted the produced binaries, and then asked go test to compile/link the complete scope again. A local cold pkg/embed race binary build took multiple minutes under load and produced a 256 MiB binary; this is directional evidence of material link work, not a CI speedup measurement.

Design

  • While the already-running exclusive issues fixture owns the cluster window, compile embedded race binaries with exactly one background compiler.
  • After issues exits, execute those exact binaries serially from each package directory through go tool test2json.
  • Keep one test process and one watchdog at execution time; no second embedded cluster is admitted.
  • Validate every binary and all -race/tag-aware package metadata before executing any binary. Any build, artifact, metadata, disk-headroom, or configuration failure falls back to the authoritative complete-scope go test before partial execution.
  • Once prebuilt execution starts, run every package and aggregate failures without rerunning earlier packages.
  • Preserve -short, race instrumentation, package identity, TestMain, -count=1, panic-on-exit, package working directory, runtime library path, and JSON output.
  • Bound each package by UT_TIMEOUT + 120s, covering TestMain cleanup and inherited-output drain beyond Go's internal test timer. TERM escalates to KILL for the complete process group.
  • Preserve single-writer ownership of UT_REPORT; scheduler diagnostics go to stderr only.
  • Require 6 GiB free workspace headroom before retaining the nine binaries.
  • Enable the path consistently in both run_ut.sh and the Makefile. Stronger runners can still override the controls.

The theoretical critical-path saving is bounded by min(issues duration, embedded compile/link duration), minus any slowdown imposed on issues by the single compiler and small per-package launch overhead. This PR does not claim a measured whole-job speedup; CI stage checkpoints will show the actual result.

Failure and cancellation contracts

The scheduler tests cover:

  • successful binary reuse;
  • build failure and missing binary fallback;
  • metadata failure fallback before any execution;
  • package failure followed by execution of remaining packages;
  • JSON-only report output on failure;
  • compilation cancellation and join-window cancellation;
  • execution cancellation while running;
  • TERM in both active-process and watchdog spawn-to-PID publication windows;
  • hard timeout with a TERM-resistant descendant and complete PGID cleanup;
  • outer cancellation with a TERM-resistant test group;
  • artifact, report, PID, and process-group cleanup.

The parent gives this two-group helper a 15-second cleanup budget, longer than the helper's 5-second TERM-to-KILL window, so it cannot kill the cleanup owner first.

Validation

  • bash -n optools/run_ut.sh: PASS
  • git diff --check origin/main...HEAD: PASS
  • go test ./optools -run '^TestEmbeddedPrebuild' -count=1: PASS
  • go test ./optools -count=1: PASS, 44.873s after rebase onto cd5feff242
  • Post-test process scan: no embedded timeout/cancellation mock processes remained.

One local direct-binary probe produced valid test2json failure JSON but could not execute on Darwin because the CI runner's Linux colon-separated rpath flags are not valid Mach-O rpaths. The repository's existing engine/plan race paths already use the same go tool test2json execution contract; no Darwin result is claimed here.

Review

Independent GPT-6 medium performed four review rounds. It found and drove fixes for external timeout/output drain, JSON pollution, preflight metadata completeness, Makefile default propagation, leader/descendant cleanup ordering, both PID publication races, outer/helper cancellation-budget ordering, and one rebase residue. Final review of commit d5c0890e41: no remaining P1/P2; safe to push.

CI is not being waited on, per request.

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner September 20, 2026 11:59
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — 当前 exact head d5c0890e4118311ff9460f1ad209dbe5819fc3af 暂不能 PASS(自有 PR,按规则只提交 COMMENT)。

optools/ut_embedded_schedule_test.go:44-73 将 go tool test2json 整体替换为 shell mock;测试没有真正启动生成的 test binary,也没有建立 test2json→binary 的输出管道。TERM-resistant 场景只验证 mock 自身忽略 TERM,未验证真实执行器在 leader 退出、后代进程仍存活或持有输出管道时的行为。

对应风险路径在 optools/run_ut.sh:2003-2011:取消/超时后需要证明后代进程组消失、管道关闭、产物清理且失败状态保留。当前 exact-head Linux CI、bash 语法和 diff 检查通过,但这些证据不能覆盖该进程拓扑生命周期缺口;Darwin UT 也未执行。

建议补充最小真实 test2json + 子进程 fixture,分别覆盖超时和外层取消,并断言上述生命周期结果。当前未确认实现本身已有泄漏或挂死,仅是该高风险契约缺少有效验证。

This branch was previously deployed

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

Labels

kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants