From 0394e32ce6b138c9815acbd1910e4753a13573db Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:23:15 +0800 Subject: [PATCH] ci: run the benchmark phases in parallel on the shared build and render one report node-24-bench becomes a two-entry matrix that restores the node-24-build output, bundles only the benchmark workers, and runs one suite phase per idle runner: phase first holds the corpus cases and phase last the serial files listed in SERIAL_BENCH_FILES. Each phase uploads its results.jsonl and the measuring environment; node-24-bench-report renders one benchmark-report on a small runner under Node type stripping and stays out of all-checks-passed. --- ...0-11-build-artifacts-check-split.i18n.yaml | 4 +- .../2026-10-11-build-artifacts-check-split.md | 3 +- ...26-10-11-build-artifacts-check-split.zh.md | 3 +- ...04-session-open-performance-gate.i18n.yaml | 4 +- ...026-09-04-session-open-performance-gate.md | 2 +- ...-09-04-session-open-performance-gate.zh.md | 2 +- ...26-10-07-scaled-benchmark-report.i18n.yaml | 4 +- .../2026-10-07-scaled-benchmark-report.md | 2 +- .../2026-10-07-scaled-benchmark-report.zh.md | 2 +- ...11-user-text-credential-matching.i18n.yaml | 4 +- ...026-10-11-user-text-credential-matching.md | 2 +- ...-10-11-user-text-credential-matching.zh.md | 2 +- .github/workflows/ci.yml | 99 ++++++++++++++-- benchmarks/AGENTS.md | 2 +- benchmarks/support/scaling-report.ts | 112 ++++++++++++++++-- docs/defensive-patterns/general.i18n.yaml | 4 +- docs/defensive-patterns/general.md | 2 +- docs/defensive-patterns/general.zh.md | 2 +- docs/testing.i18n.yaml | 4 +- docs/testing.md | 2 +- docs/testing.zh.md | 2 +- package.json | 1 + scripts/bench-phase.ts | 21 ++++ scripts/ci-workflow.spec.ts | 95 +++++++++++---- scripts/render-benchmark-report.spec.ts | 80 +++++++++++++ scripts/render-benchmark-report.ts | 14 +++ scripts/run-bench-suite.ts | 11 +- scripts/run-ci-bench.ts | 41 ++++++- scripts/run-gates.spec.ts | 21 ++++ scripts/run-gates.ts | 18 ++- 30 files changed, 491 insertions(+), 74 deletions(-) create mode 100644 scripts/bench-phase.ts create mode 100644 scripts/render-benchmark-report.spec.ts create mode 100644 scripts/render-benchmark-report.ts diff --git a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.i18n.yaml b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.i18n.yaml index f830421900..611f01dd80 100644 --- a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.i18n.yaml +++ b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.i18n.yaml @@ -21,8 +21,8 @@ en: 6a1b4ed0d9910133 zh: f32c6882208ded71 /agent-note-split-build-artifacts-and-build-check-with-build-running-both-concurrently/decision/callers: - en: dad172a1cabc42cb - zh: 0180238dcb53ee3f + en: 130636aa0395c746 + zh: 0314fe0490f64410 /agent-note-split-build-artifacts-and-build-check-with-build-running-both-concurrently/decision/measurements: en: b3a753ac2aab6073 zh: 19cbd0e32751896f diff --git a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.md b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.md index 8f43ccd136..2a49a391dd 100644 --- a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.md +++ b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.md @@ -55,7 +55,8 @@ Each command does only its own job. | CI python runtime | `build-exe-for-python-sdk.ts --build-artifacts` | None | | PR rehearsals in `e2e.yml` and `release.yml` | `pnpm run build:artifacts --profile official` | None | | `build-preview-cloudflare.yml` | `pnpm run build:artifacts` | None | -| CI node 24 / benchmarks | `run-ci-bench.ts` (`tsc -b --noCheck`) | None | +| CI node 24 / benchmarks 1/2 and 2/2 | None: they restore the `node 24 / build` output and bundle only `benchmarks/.dsh-build/` workers | None | +| `check:ci:bench` | `run-ci-bench.ts` (`tsc -b --noCheck`) | None | | PR rehearsal in `release-vendor.yml` | `compile-referenced-projects.ts host-libraries` | None | | Non-PR branch of `release-vendor.yml`, `release-vendor-publish.yml` | `build:lib:host` | Host aggregate root program only | diff --git a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.zh.md b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.zh.md index 8eb2ed11e0..195bee3bef 100644 --- a/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.zh.md +++ b/.agents/notes/implemented/process/2026-10-11-build-artifacts-check-split.zh.md @@ -55,7 +55,8 @@ Status: implemented | CI python runtime | `build-exe-for-python-sdk.ts --build-artifacts` | 无 | | `e2e.yml`、`release.yml` 的 PR 演练 | `pnpm run build:artifacts --profile official` | 无 | | `build-preview-cloudflare.yml` | `pnpm run build:artifacts` | 无 | -| CI node 24 / benchmarks | `run-ci-bench.ts`(`tsc -b --noCheck`) | 无 | +| CI node 24 / benchmarks 1/2 与 2/2 | 无:恢复 `node 24 / build` 产物,只打包 `benchmarks/.dsh-build/` worker | 无 | +| `check:ci:bench` | `run-ci-bench.ts`(`tsc -b --noCheck`) | 无 | | `release-vendor.yml` 的 PR 演练 | `compile-referenced-projects.ts host-libraries` | 无 | | `release-vendor.yml` 的非 PR 分支、`release-vendor-publish.yml` | `build:lib:host` | 仅 Host 聚合根程序 | diff --git a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.i18n.yaml b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.i18n.yaml index d03a5ff8c5..89ad1182b6 100644 --- a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.i18n.yaml +++ b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.i18n.yaml @@ -9,8 +9,8 @@ en: 00ba1f66195351e2 zh: a738b81adceda351 /agent-note-required-ci-performance-gate-for-opening-large-sessions/decision: - en: 4f94b61c48cceaf4 - zh: dbb51bfe1fb0f681 + en: 70b42dc07ef01b87 + zh: 3a04fd4225ac5d34 /agent-note-required-ci-performance-gate-for-opening-large-sessions/calibration-evidence: en: f1001a139470f6b7 zh: b7b46f96b84b1271 diff --git a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md index 926203ea5b..ee3606138c 100644 --- a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md +++ b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md @@ -12,7 +12,7 @@ Measuring only `SessionPersistence.open()` does not stably describe the result f ## Decision -Linux pull requests run a required `node 24 / benchmarks` job that executes `pnpm run check:ci:bench` → `scripts/run-ci-bench.ts`. Its disposable library build omits repeated TypeScript diagnostics under the [PR artifact build policy](../process/2026-10-05-pr-artifact-typechecks.md); required full builds retain them. The private `@deepseek-ai/dsh-benchmarks` workspace owns benchmark-only dependencies. The command first builds workspace libraries and dedicated workers under `benchmarks/.dsh-build/`, then invokes `vitest.bench.config.ts`. The [standard hosted runner reference](../../../../.github/workflows/ci.yml) owns runner selection and the outer job timeout. The job runs the benchmark lane alone; Vitest runs one file at a time and only prepares input, starts measurement children, aggregates results, and enforces budgets. Every timed Node CPU path executes compiled JavaScript under plain Node with `NODE_OPTIONS` removed and no TypeScript loader; bare workspace imports therefore resolve from `benchmarks/node_modules` through package exports to built `lib/` entries. +Linux pull requests run the required `node 24 / benchmarks 1/2` and `2/2` jobs, one per suite phase, through `pnpm run check:ci:bench-prebuilt` → `scripts/run-ci-bench.ts --phase`. They restore the libraries, native addon, and Web assets from `node 24 / build` and build only the benchmark workers; `pnpm run check:ci:bench` keeps the self-contained disposable library build, which omits repeated TypeScript diagnostics under the [PR artifact build policy](../process/2026-10-05-pr-artifact-typechecks.md). The private `@deepseek-ai/dsh-benchmarks` workspace owns benchmark-only dependencies. The command first builds workspace libraries and dedicated workers under `benchmarks/.dsh-build/`, then invokes `vitest.bench.config.ts`. The [standard hosted runner reference](../../../../.github/workflows/ci.yml) owns runner selection and the outer job timeout. The job runs the benchmark lane alone; Vitest runs one file at a time and only prepares input, starts measurement children, aggregates results, and enforces budgets. Every timed Node CPU path executes compiled JavaScript under plain Node with `NODE_OPTIONS` removed and no TypeScript loader; bare workspace imports therefore resolve from `benchmarks/node_modules` through package exports to built `lib/` entries. Required performance gates live under top-level `benchmarks/`, grouped by measured user path rather than package ownership. Host files use `*.bench.ts`, Client-face files use `*.bench.client.ts`, and scenario-specific workers and fixtures stay beside their benchmark without a benchmark suffix. Package-local `.perf.ts` files remain non-gating diagnostics; `scripts/` owns orchestration rather than benchmark cases. diff --git a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md index e8a64dca20..8bf558b3da 100644 --- a/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md +++ b/.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md @@ -12,7 +12,7 @@ Session format v2 的推出改变了两条成本随模型输出增长的路径 ## 决定 -Linux pull request 运行必需的 `node 24 / benchmarks` job,执行 `pnpm run check:ci:bench` → `scripts/run-ci-bench.ts`。其临时 library 构建按 [PR 产物构建政策](../process/2026-10-05-pr-artifact-typechecks.zh.md)省略重复的 TypeScript 诊断;必需的完整构建保留这些诊断。私有 `@deepseek-ai/dsh-benchmarks` workspace 拥有 benchmark 专属依赖。该命令先构建 workspace library 和 `benchmarks/.dsh-build/` 下的专用 worker,再调用 `vitest.bench.config.ts`。[标准托管运行器说明](../../../../.github/workflows/ci.yml)拥有运行器选择及外层 job 超时。该 job 单独运行 benchmark lane;Vitest 逐文件运行,只负责准备输入、启动测量子进程、汇总结果和执行预算断言。每条被计时的 Node CPU 路径都以纯 Node 执行编译后的 JavaScript,并移除 `NODE_OPTIONS` 且不加载 TypeScript runtime;workspace 裸导入因此从 `benchmarks/node_modules` 通过 package exports 解析到构建后的 `lib/` 入口。 +Linux pull request 运行必需的 `node 24 / benchmarks 1/2` 与 `2/2` job,每个对应一个套件阶段,经 `pnpm run check:ci:bench-prebuilt` → `scripts/run-ci-bench.ts --phase` 运行。它们恢复 `node 24 / build` 的 library、原生插件与 Web 资源,只构建 benchmark worker;`pnpm run check:ci:bench` 保留自带的临时 library 构建,按 [PR 产物构建政策](../process/2026-10-05-pr-artifact-typechecks.zh.md)省略重复的 TypeScript 诊断。私有 `@deepseek-ai/dsh-benchmarks` workspace 拥有 benchmark 专属依赖。该命令先构建 workspace library 和 `benchmarks/.dsh-build/` 下的专用 worker,再调用 `vitest.bench.config.ts`。[标准托管运行器说明](../../../../.github/workflows/ci.yml)拥有运行器选择及外层 job 超时。该 job 单独运行 benchmark lane;Vitest 逐文件运行,只负责准备输入、启动测量子进程、汇总结果和执行预算断言。每条被计时的 Node CPU 路径都以纯 Node 执行编译后的 JavaScript,并移除 `NODE_OPTIONS` 且不加载 TypeScript runtime;workspace 裸导入因此从 `benchmarks/node_modules` 通过 package exports 解析到构建后的 `lib/` 入口。 必需性能 gate 位于顶层 `benchmarks/`,按被测用户路径而非 package 归属组织。Host 文件使用 `*.bench.ts`,Client 面文件使用 `*.bench.client.ts`,场景专属 worker 与 fixture 留在对应 benchmark 旁且不带 benchmark 后缀。包内 `.perf.ts` 文件仍是非门禁诊断;`scripts/` 负责编排而不承载 benchmark case。 diff --git a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.i18n.yaml b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.i18n.yaml index bd483649b5..efb6e0f173 100644 --- a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.i18n.yaml +++ b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.i18n.yaml @@ -24,5 +24,5 @@ en: 9011ce1b4702608d zh: 214f38794afe13fd /agent-note-scaled-machine-and-memory-pressure-benchmark-report/consequences: - en: af04c3e97e85f1e3 - zh: 533a73e06f708c9d + en: 29a1c6d9f4d55f0d + zh: 2cdf8e50c810059e diff --git a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.md b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.md index 3b800774cc..c395c1507c 100644 --- a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.md +++ b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.md @@ -40,4 +40,4 @@ Long-Session `first`, `input`, and `streamWall` include paced replay waits and a ## Consequences -Readers can see each endpoint on reviewed machines with measured defaults, and adjust the storage share, without changing any gate. The page depends on reviewed constants: cross-ISA ratings, shared vCPUs, and disk latency classes are coarse, so results are estimates rather than measurements. The memory view does not measure swap or reclaim costs. The `node 24 / benchmarks` job publishes the page as the `benchmark-report` artifact. +Readers can see each endpoint on reviewed machines with measured defaults, and adjust the storage share, without changing any gate. The page depends on reviewed constants: cross-ISA ratings, shared vCPUs, and disk latency classes are coarse, so results are estimates rather than measurements. The memory view does not measure swap or reclaim costs. The `node 24 / benchmark report` job renders the page from the results of both benchmark phase jobs and publishes it as the `benchmark-report` artifact. diff --git a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.zh.md b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.zh.md index 83182c650e..31da8da383 100644 --- a/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.zh.md +++ b/.agents/notes/implemented/testing/2026-10-07-scaled-benchmark-report.zh.md @@ -40,4 +40,4 @@ Session 语料的列表、搜索和 fork 用例报告最大合成工作集的整 ## 影响 -读者可以在经审阅的机器上查看每个端点及其实测默认值,并调整存储占比,而不改变任何门禁。页面依赖经审阅的常量:跨指令集评分、共享 vCPU 和磁盘延迟等级都较粗略,因此结果是估计值而不是测量值。内存视图不测量交换和回收成本。`node 24 / benchmarks` job 将该页面作为 `benchmark-report` 产物发布。 +读者可以在经审阅的机器上查看每个端点及其实测默认值,并调整存储占比,而不改变任何门禁。页面依赖经审阅的常量:跨指令集评分、共享 vCPU 和磁盘延迟等级都较粗略,因此结果是估计值而不是测量值。内存视图不测量交换和回收成本。`node 24 / benchmark report` job 用两个基准阶段 job 的结果渲染该页面,并作为 `benchmark-report` 产物发布。 diff --git a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.i18n.yaml b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.i18n.yaml index 778be9ae01..4116756217 100644 --- a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.i18n.yaml +++ b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.i18n.yaml @@ -21,8 +21,8 @@ en: f07bb6fbbdd01fe4 zh: 9313a0ef2a22af12 /agent-note-linear-credential-matching-and-performance-gates-for-user-text/decision/performance-gate: - en: 3ceb80f455e9a47d - zh: 89d8bd11b42d31b0 + en: df973db37213319a + zh: 0a87f164f8dec4f9 /agent-note-linear-credential-matching-and-performance-gates-for-user-text/alternatives-considered: en: b5bfb4cfa231ce0f zh: 631b9f2978241bc1 diff --git a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.md b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.md index 7c92d9c72e..c1bd66948e 100644 --- a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.md +++ b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.md @@ -38,7 +38,7 @@ English | [中文](2026-10-11-user-text-credential-matching.zh.md) ### Performance gate -[benchmarks/user-text](../../../../benchmarks/user-text/user-text.bench.client.ts) runs in the required `node 24 / benchmarks` lane. Its compiled worker uses the production UserText registry and every shipped matcher (session, file, folder, skill, command, whitespace, credential) under plain Node, in two processes: timing and allocation. +[benchmarks/user-text](../../../../benchmarks/user-text/user-text.bench.client.ts) runs in the required `node 24 / benchmarks 2/2` lane. Its compiled worker uses the production UserText registry and every shipped matcher (session, file, folder, skill, command, whitespace, credential) under plain Node, in two processes: timing and allocation. | Item | Content | |---|---| diff --git a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.zh.md b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.zh.md index f5b31146b8..74cab1b544 100644 --- a/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.zh.md +++ b/.agents/notes/implemented/testing/2026-10-11-user-text-credential-matching.zh.md @@ -38,7 +38,7 @@ Status: implemented ### 性能门禁 -[benchmarks/user-text](../../../../benchmarks/user-text/user-text.bench.client.ts) 在 `node 24 / benchmarks` 必跑 lane 中运行。编译后的 worker 使用生产的 UserText 注册表和全部已发布匹配器(会话、文件、文件夹、skill、命令、空白、凭据),在纯 Node 下分两个进程运行:计时与分配。 +[benchmarks/user-text](../../../../benchmarks/user-text/user-text.bench.client.ts) 在 `node 24 / benchmarks 2/2` 必跑 lane 中运行。编译后的 worker 使用生产的 UserText 注册表和全部已发布匹配器(会话、文件、文件夹、skill、命令、空白、凭据),在纯 Node 下分两个进程运行:计时与分配。 | 项 | 内容 | |---|---| diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cba2a805fd..2cb64bc1e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -417,17 +417,33 @@ jobs: - name: Run lint and duplication run: pnpm run check:ci:lint:contracts-ready + # The two suite phases run on separate idle runners from the shared build + # output: phase `first` holds the corpus cases that tolerate a sibling and + # phase `last` the browser, animation-frame, and fresh-child cases that need + # an idle runner (SERIAL_BENCH_FILES in scripts/run-bench-suite.ts). node-24-bench: + needs: node-24-build if: github.event_name == 'pull_request' runs-on: >- ${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-24.04' }} - name: node 24 / benchmarks - # Wall-clock budgets need an otherwise idle runner, so this job runs the - # benchmark lane alone instead of joining a concurrent gate aggregate, and - # keeps its own two-file parallelism inside that runner. The self-hosted - # failover pool is shared, so the benchmarks stay on hosted Linux there. + strategy: + fail-fast: false + matrix: + include: + - shard: 1 + phase: first + - shard: 2 + phase: last + name: node 24 / benchmarks ${{ matrix.shard }}/2 + # Wall-clock budgets need an otherwise idle runner, so each phase runs + # alone on its runner instead of joining a concurrent gate aggregate; the + # first phase keeps its own two-file parallelism inside that runner. The + # self-hosted failover pool is shared, so the benchmarks stay on hosted + # Linux there. timeout-minutes: 20 + env: + DSH_BENCH_PHASE: ${{ matrix.phase }} steps: - uses: actions/checkout@v7.0.1 with: @@ -459,18 +475,81 @@ jobs: - name: Install (immutable) run: pnpm install --frozen-lockfile + - name: Download build output + uses: actions/download-artifact@v8.0.1 + with: + name: build-output + path: ${{ runner.temp }}/build-output + + - name: Unpack build output + run: | + set -o pipefail + archive="$RUNNER_TEMP/build-output/build-output.tar.zst" + # -m stamps restored files with the extraction time: newer than this + # checkout and never in the future. + zstd -dc -T0 "$archive" | tar -xmf - + test -f apps/cli/lib/bin.js && test -f apps/web/dist/index.html && test -f .dsh-build/client-build-environment.json + - name: Install benchmark browser and hosted dependencies run: pnpm --filter @deepseek-ai/dsh-benchmarks exec playwright install --with-deps chromium - name: Run performance benchmarks env: DSH_GATE_VERBOSE: '1' - run: pnpm run check:ci:bench + run: pnpm run check:ci:bench-prebuilt + + # The report global teardown writes results.jsonl and environment.json + # after the run, including after a failing budget assertion; the report + # job renders both phases into one report. A phase that fails before + # recording any timing has no results, so missing files warn. + - name: Upload benchmark results + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v7.0.1 + with: + name: benchmark-results-${{ matrix.shard }} + path: benchmarks/.dsh-report/ + include-hidden-files: true + if-no-files-found: warn + retention-days: 7 + # A re-run of this phase replaces the previous attempt's results. + overwrite: true + + # Bookkeeping only: renders one scaled report from both phases, including + # after a failing budget. The benchmark verdict comes from node-24-bench, so + # this job stays out of all-checks-passed. + node-24-bench-report: + needs: node-24-bench + if: ${{ !cancelled() && github.event_name == 'pull_request' }} + runs-on: >- + ${{ vars.DSH_CI_FAILOVER_LINUX == 'blacksmith' && 'blacksmith-2vcpu-ubuntu-2404' + || 'ubuntu-latest' }} + name: node 24 / benchmark report + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-node@v7.0.0 + with: + node-version: ${{ env.PRIMARY_NODE_VERSION }} + + - name: Download benchmark results + uses: actions/download-artifact@v8.0.1 + with: + pattern: benchmark-results-* + path: ${{ runner.temp }}/benchmark-results + + # The renderer runs under Node type stripping and needs no install. + - name: Render scaled benchmark report + run: | + shopt -s nullglob + phases=("$RUNNER_TEMP"/benchmark-results/*/) + if (( ${#phases[@]} == 0 )); then + echo "::warning::No benchmark phase uploaded results." + exit 0 + fi + node scripts/render-benchmark-report.ts benchmarks/.dsh-report "${phases[@]}" - # The report global teardown renders benchmarks/.dsh-report after the run, - # including after a failing budget assertion. A run that fails before - # recording any timing has no report, so missing files warn instead of - # failing the benchmark job a second time. - name: Upload scaled benchmark report if: ${{ !cancelled() }} uses: actions/upload-artifact@v7.0.1 diff --git a/benchmarks/AGENTS.md b/benchmarks/AGENTS.md index eda9f8cad3..8e8cd5fbbe 100644 --- a/benchmarks/AGENTS.md +++ b/benchmarks/AGENTS.md @@ -8,7 +8,7 @@ This tree owns required, repository-level performance gates whose measured user - Browser workflow cases drive built Client bundles through the shared shipped-composition Web scaffold. Report its source-resolved test Host separately from published-Host evidence; two animation frames prove a rendering opportunity, not hardware presentation. Use fresh browsers and private scaffold worlds per sample. - Synthesize fixed inputs from reviewed constants. Never use recorded Sessions, user material, ambient repositories, or network services. - Run process-level wall-clock and retained-memory samples in fresh children with private `mkdtemp` roots. Pure synchronous folds create a fresh object graph per sample and must not mutate process-global state. Bound every child, await exit, and remove owned roots after failure as well as success. -- Pass every budgeted wall-clock endpoint to `recordTimings` from `support/scaling-report.ts` before asserting it, with a `BenchmarkCase` stating what it measures and which user scenario it affects. Give each endpoint its process CPU time over the same interval when the worker can measure it, otherwise a commented storage-wait share; omit endpoints that include paced or fixed waits. Pass whole-process peak RSS to `recordPeakMemory`. Profiles live in `support/machine-profiles.ts`; each run writes `.dsh-report/report.html`, which the `node 24 / benchmarks` job publishes as the `benchmark-report` artifact. +- Pass every budgeted wall-clock endpoint to `recordTimings` from `support/scaling-report.ts` before asserting it, with a `BenchmarkCase` stating what it measures and which user scenario it affects. Give each endpoint its process CPU time over the same interval when the worker can measure it, otherwise a commented storage-wait share; omit endpoints that include paced or fixed waits. Pass whole-process peak RSS to `recordPeakMemory`. Profiles live in `support/machine-profiles.ts`; each run writes `.dsh-report/report.html`, and CI renders one page from both benchmark phase jobs in `node 24 / benchmark report`, published as the `benchmark-report` artifact. - Record reference-machine expectations separately from the shared CI time scale and variance headroom. Do not apply the time scale to memory or dimensionless ratios. - Report enough raw and aggregate measurements to explain each verdict, including whether a budget uses a median, minimum, absolute value, or ratio. Enforce reviewed source constants; environment variables must not override performance budgets. - Keep scenario-specific support beside its benchmark. Move a helper into `benchmarks/support/` only after at least two benchmark directories require the same behavior. diff --git a/benchmarks/support/scaling-report.ts b/benchmarks/support/scaling-report.ts index 6345dde870..2a20ead10b 100644 --- a/benchmarks/support/scaling-report.ts +++ b/benchmarks/support/scaling-report.ts @@ -24,8 +24,11 @@ import { MACHINE_PROFILES, matchMachineProfile } from './machine-profiles.ts' /** Directory owning `results.jsonl` and `report.html`; ignored by Git. */ export const REPORT_DIRECTORY = join(import.meta.dirname, '..', '.dsh-report') -const RESULTS_PATH = join(REPORT_DIRECTORY, 'results.jsonl') -const REPORT_PATH = join(REPORT_DIRECTORY, 'report.html') +const RESULTS_FILE = 'results.jsonl' +const ENVIRONMENT_FILE = 'environment.json' +const REPORT_FILE = 'report.html' +const RESULTS_PATH = join(REPORT_DIRECTORY, RESULTS_FILE) +const REPORT_PATH = join(REPORT_DIRECTORY, REPORT_FILE) /** Identity and reader-facing description of one benchmark case, shown when hovering its rows in the report. */ export interface BenchmarkCase { @@ -120,23 +123,112 @@ export function setup(): void { rmSync(REPORT_DIRECTORY, { recursive: true, force: true }) } -/** Vitest global teardown: render the report when a case recorded a timing and this phase owns the report. */ +/** + * Vitest global teardown: when a case recorded a timing and this phase owns the report, render it and + * record the measuring machine beside the results, so {@link mergeReportDirectories} can render one + * report from phases measured on separate machines. + */ export function teardown(): void { if (reportPhase() === 'first') return if (!existsSync(RESULTS_PATH)) return - const records = readFileSync(RESULTS_PATH, 'utf8').split('\n').filter(line => line !== '').map(line => JSON.parse(line) as TimingRecord | MemoryRecord) - const cpuModel = cpus()[0]?.model.trim() ?? 'unknown CPU' + const environment = measuringEnvironment() + writeFileSync(join(REPORT_DIRECTORY, ENVIRONMENT_FILE), `${JSON.stringify(environment)}\n`) writeFileSync(REPORT_PATH, renderReport({ - records, + records: readRecords(RESULTS_PATH), + ...environment, + revision: process.env['GITHUB_SHA'], + generatedAt: new Date().toISOString(), + })) + console.log(`benchmark report: ${REPORT_PATH}`) +} + +/** The machine fields of {@link ReportData}, measured by the process that ran the cases. */ +export type MeasuringEnvironment = Pick + +function measuringEnvironment(): MeasuringEnvironment { + const cpuModel = cpus()[0]?.model.trim() ?? 'unknown CPU' + return { cpuModel, platform: `${process.platform}-${process.arch}`, node: process.version, - revision: process.env['GITHUB_SHA'], - generatedAt: new Date().toISOString(), cores: availableParallelism(), measuredProfile: matchMachineProfile(cpuModel), - })) - console.log(`benchmark report: ${REPORT_PATH}`) + } +} + +function readRecords(path: string): (TimingRecord | MemoryRecord)[] { + return readFileSync(path, 'utf8').split('\n').filter(line => line !== '').map(line => JSON.parse(line) as TimingRecord | MemoryRecord) +} + +function readEnvironment(path: string): MeasuringEnvironment { + const value: unknown = JSON.parse(readFileSync(path, 'utf8')) + if (typeof value !== 'object' || value === null) throw new Error(`${path} must hold a JSON object.`) + const field = (name: string): unknown => Reflect.get(value, name) + const cpuModel = field('cpuModel') + const platform = field('platform') + const node = field('node') + const cores = field('cores') + const measuredProfile = field('measuredProfile') + if (typeof cpuModel !== 'string' || typeof platform !== 'string' || typeof node !== 'string' + || typeof cores !== 'number' || !Number.isInteger(cores) || cores < 1 + || (measuredProfile !== undefined && typeof measuredProfile !== 'string')) { + throw new Error(`${path} must record cpuModel, platform, node, a positive integer cores, and an optional measuredProfile.`) + } + return { cpuModel, platform, node, cores, measuredProfile } +} + +/** + * Combine the results of phases that each ran alone on its own machine into the inputs of one report. + * Records are concatenated in directory order. When every phase reports the same machine, the report + * uses it; otherwise the CPU models are listed together and the measured profile is left for the reader + * to choose, because one profile cannot describe both machines. + * @param directories - report directories, each holding `results.jsonl` and `environment.json`. + * @param revision - commit the phases measured. + * @param generatedAt - render time. + * @returns the report inputs and any machine mismatch to surface. + * @throws If no directory holds results, or a directory holds results without a valid environment. + */ +export function mergeReportDirectories( + directories: readonly string[], + revision: string | undefined, + generatedAt: string, +): { readonly data: ReportData; readonly warnings: readonly string[] } { + const phases = directories + .filter(directory => existsSync(join(directory, RESULTS_FILE))) + .map(directory => ({ + records: readRecords(join(directory, RESULTS_FILE)), + environment: readEnvironment(join(directory, ENVIRONMENT_FILE)), + })) + const [first] = phases + if (first === undefined) throw new Error(`no benchmark results under ${JSON.stringify(directories)}.`) + const models = [...new Set(phases.map(phase => phase.environment.cpuModel))] + const warnings = models.length > 1 + ? [`benchmark phases ran on different CPUs (${models.join(' | ')}); choose the measured profile in the report.`] + : [] + return { + data: { + records: phases.flatMap(phase => phase.records), + ...first.environment, + ...models.length > 1 ? { cpuModel: models.join(' | '), measuredProfile: undefined } : {}, + revision, + generatedAt, + }, + warnings, + } +} + +/** + * Render one report from several phase report directories into `outputDirectory/report.html`. + * @param outputDirectory - directory to write the report into. + * @param directories - phase report directories; ones without results are skipped. + * @returns the warnings from {@link mergeReportDirectories}. + * @throws If no directory holds results. + */ +export function renderMergedReport(outputDirectory: string, directories: readonly string[]): readonly string[] { + const { data, warnings } = mergeReportDirectories(directories, process.env['GITHUB_SHA'], new Date().toISOString()) + mkdirSync(outputDirectory, { recursive: true }) + writeFileSync(join(outputDirectory, REPORT_FILE), renderReport(data)) + return warnings } /** Inputs embedded in one rendered report. */ diff --git a/docs/defensive-patterns/general.i18n.yaml b/docs/defensive-patterns/general.i18n.yaml index fecd9d26cd..1878a2daeb 100644 --- a/docs/defensive-patterns/general.i18n.yaml +++ b/docs/defensive-patterns/general.i18n.yaml @@ -36,8 +36,8 @@ en: f74f2467e507455f zh: fe1bae04be5ad63a /defensive-patterns/changes-carry-performance-evidence: - en: 0d6855d1ae0ef4ae - zh: 0f771999398ce052 + en: ed9da54674e60a52 + zh: e7d155cd17651ff9 /defensive-patterns/migrations-preserve-behavior: en: 6213e051f51437b8 zh: 853580b3a4fec100 diff --git a/docs/defensive-patterns/general.md b/docs/defensive-patterns/general.md index 165d416d21..a310a76ce2 100644 --- a/docs/defensive-patterns/general.md +++ b/docs/defensive-patterns/general.md @@ -192,7 +192,7 @@ Measurement is owned by [benchmarks/](../../benchmarks/AGENTS.md), one directory pnpm run test:bench ``` -Package-local diagnostics stay beside their owner with the `.perf.ts` suffix and do not join `test:bench`. The CI gate is `pnpm run check:ci:bench` (job `node 24 / benchmarks`), which publishes a scaled report — that gate is an alert, not a pass: a regression there is located by re-running the owning scenario and profiling segments locally to find which part slowed and which change introduced it. Retained-memory claims use `pnpm run test:bench:memory 4g|8g`, which reruns its listed files under an unchanged budget in a swapless cgroup. +Package-local diagnostics stay beside their owner with the `.perf.ts` suffix and do not join `test:bench`. The CI gates are the two phase jobs `node 24 / benchmarks 1/2` and `2/2` (`pnpm run check:ci:bench-prebuilt`), and `node 24 / benchmark report` publishes a scaled report from both — that gate is an alert, not a pass: a regression there is located by re-running the owning scenario and profiling segments locally to find which part slowed and which change introduced it. Retained-memory claims use `pnpm run test:bench:memory 4g|8g`, which reruns its listed files under an unchanged budget in a swapless cgroup. Boundaries: edits that touch no runtime path — comments, documentation, test-only code — need no measurement, and production performance code is not benchmark instrumentation to be deleted opportunistically (`performance.now()` and `scheduler.yield()` are part of production decode and encode chunk scheduling). An architectural change that genuinely costs performance states the measured cost and the reason, and the domain owner approves it; "the layering needed it" is not a self-service reason. Record the command, the numbers, the environment, and the input size so the baseline can be rebuilt. diff --git a/docs/defensive-patterns/general.zh.md b/docs/defensive-patterns/general.zh.md index 8013ec28fd..fa8794815d 100644 --- a/docs/defensive-patterns/general.zh.md +++ b/docs/defensive-patterns/general.zh.md @@ -214,7 +214,7 @@ if (pluginName === 'ui-attachment') { /* business branch inside the manager */ } pnpm run test:bench ``` -包内诊断留在包旁边、用 `.perf.ts` 后缀,不进 `test:bench`。CI 门禁是 `pnpm run check:ci:bench`(作业 `node 24 / benchmarks`),产出 scaled report——该门禁只是**报警**,不是通过依据:出现退化时重跑对应场景并本地分段 profile,定位是哪一段变慢、哪次变更引入。内存留存类结论用 `pnpm run test:bench:memory 4g|8g`,它会在无 swap 的 cgroup 里以不变预算重跑其列出的文件。 +包内诊断留在包旁边、用 `.perf.ts` 后缀,不进 `test:bench`。CI 门禁是两个阶段作业 `node 24 / benchmarks 1/2` 与 `2/2`(`pnpm run check:ci:bench-prebuilt`),由 `node 24 / benchmark report` 汇总两者产出 scaled report——该门禁只是**报警**,不是通过依据:出现退化时重跑对应场景并本地分段 profile,定位是哪一段变慢、哪次变更引入。内存留存类结论用 `pnpm run test:bench:memory 4g|8g`,它会在无 swap 的 cgroup 里以不变预算重跑其列出的文件。 边界:不触碰运行路径的改动——注释、文档、仅测试代码——不需要测量;生产性能代码不是可以顺手删掉的 benchmark instrumentation(`performance.now()`、`scheduler.yield()` 属于生产 decode/encode 分片调度的一部分)。架构调整确实要付出性能代价时,写明实测代价与理由,并由对应领域专家确认;「分层需要」不是自助理由。命令、数字、环境与输入规模都要落账,以便返工时重建同一基线。 diff --git a/docs/testing.i18n.yaml b/docs/testing.i18n.yaml index 879a5e290a..bf70bb4b3c 100644 --- a/docs/testing.i18n.yaml +++ b/docs/testing.i18n.yaml @@ -6,8 +6,8 @@ en: 0d7399a58529b9eb zh: 7f445b06430f21a4 /testing-policy/tiers: - en: ae5eb9cc384542cb - zh: 3473df2dc1e36bd0 + en: 29e64525fdf54929 + zh: bbddb2a55022e525 /testing-policy/how-specs-execute: en: 022c534e72e23142 zh: c07a20994224f37c diff --git a/docs/testing.md b/docs/testing.md index 9064aef93d..3c6051ba6b 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -10,7 +10,7 @@ How this repo tests, tier by tier, and the rules that keep a green suite meaning - **Coverage gate** (`pnpm run test:coverage`): the gating run, per-file 100% on `packages/*/*/src`. An uncovered line is often dead code the gate flags for deletion, not a missing test to bolt on. Line coverage is necessary, never sufficient — it proves lines ran, not that the feature works as shipped. Per-file 100% on `packages/shell/pwsh-local/src` needs a real `pwsh`: without one its executor suites self-skip and `vitest.config.ts` exempts the file so pwsh-less hosts stay green, while CI runners ship pwsh and enforce the full bar. - **Real-API e2e** (`pnpm run test:e2e`): with-key tests against live provider APIs — the DeepSeek model plus provider-specific smokes that gate on their own keys; each suite self-skips without its key so keyless CI stays green ([real-API e2e Agent Note](../.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.md)). - **Owner-local expected output** (`pnpm run test:expected`): keyless assembled CLI/process expectations without a recorded-session round trip. Drivers use `*.expected.e2e.ts` beside `tests/expected/`; CI runs built exports. Package/script expectations use `test`, while browser expectations use `test:web`. -- **Performance benchmarks** (`pnpm run test:bench`; required Linux PR gate `node 24 / benchmarks`): `benchmarks/` groups user-path gates. It builds libraries and workers; timed code runs under plain Node, never TSX. Synthetic inputs enforce time, heap, and scaling budgets; package-local `.perf.ts` stays diagnostic ([rules](../.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md)). +- **Performance benchmarks** (`pnpm run test:bench`; required Linux PR gates `node 24 / benchmarks 1/2` and `2/2`): `benchmarks/` groups user-path gates. It builds libraries and workers; timed code runs under plain Node, never TSX. Synthetic inputs enforce time, heap, and scaling budgets; package-local `.perf.ts` stays diagnostic ([rules](../.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md)). - **Snapshot** (`pnpm run test:snapshot`): a top-level scenario's highest recorded parent generation supplies user input and model replay, then serves as the expected persisted result. Parent filenames are `session[.vN].jsonl`; child roles are `session.[.vN].jsonl`; v0 omits `.v0`, positive versions require lowercase `.vN`, and each filename must agree with its header. Process scenarios start through `dsh`: headless owns one-shot behavior, the SDK owns persistent control, ACP owns automation-protocol behavior, and Web retains browser/ARIA evidence beside the same Session. `snapshot.yml` declares the profile, composition/header class, recording policy, exceptional replay or input metadata, and workspace facts. Typed tokens preserve parent/child identity relationships; only header pins own prompt/schema sidecars. A mutating scenario independently compares the complete `workspace.expected/` tree, which record and refresh never rewrite. Use `test:snapshot:record` when a model transcript changes and `test:snapshot:refresh` when replay input remains valid; review every resulting diff. - **Web browser snapshot** (`pnpm run test:web`; required Linux PR gate): The command builds plugin CSS, then compares all session-driven `snapshots/web/` and UI-only `apps/web/tests/expected/` output in Chromium; the model/reasoning picker also runs in WebKit. CI enforces read-only `DSH_SNAPSHOT=replay`; record/refresh stay local, with every diff reviewed ([web lane](../.agents/notes/implemented/testing/2026-07-24-web-gui-browser-e2e-lane.md), [CI reference](../scripts/run-web-snapshots.ts)). diff --git a/docs/testing.zh.md b/docs/testing.zh.md index f756cc9306..ae644fbe97 100644 --- a/docs/testing.zh.md +++ b/docs/testing.zh.md @@ -10,7 +10,7 @@ - **覆盖率门禁**(`pnpm run test:coverage`):门禁级运行,对 `packages/*/*/src` 按文件 100% 覆盖。未覆盖的行往往是门禁正确标记出的死代码(应删除),而非需要补写的测试。行覆盖率是必要条件,但永远不是充分条件:它证明行被执行过,不证明功能按交付预期工作。`packages/shell/pwsh-local/src` 的按文件 100% 覆盖需要真实的 `pwsh`:缺少它时其执行器套件会自动跳过,`vitest.config.ts` 会豁免该文件以使无 pwsh 的主机保持绿色,而 CI runner 自带 pwsh,仍按完整标准执行门禁。 - **真实 API e2e**(`pnpm run test:e2e`):带密钥测试调用真实提供方 API,包括 DeepSeek 模型以及各提供方特有的冒烟测试;这些测试各自由自己的密钥控制,缺少密钥时套件会自动跳过,使 keyless CI 保持绿色([真实 API e2e Agent Note](../.agents/notes/implemented/testing/2026-06-19-real-api-e2e-ci.zh.md))。 - **所属位置的预期输出**(`pnpm run test:expected`):无录制会话往返的无密钥组装 CLI/进程预期。驱动使用 `*.expected.e2e.ts`,并与 `tests/expected/` 同属一处;CI 针对构建产物运行。包/脚本预期使用 `test`,浏览器预期使用 `test:web`。 -- **性能基准**(`pnpm run test:bench`;必需的 Linux PR gate `node 24 / benchmarks`):`benchmarks/` 按用户路径组织门禁。它先构建 library 和 worker;被计时代码在纯 Node 下运行,不使用 TSX。合成输入执行耗时、堆和缩放预算;包内 `.perf.ts` 保留为诊断([规则](../.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md))。 +- **性能基准**(`pnpm run test:bench`;必需的 Linux PR gate `node 24 / benchmarks 1/2` 与 `2/2`):`benchmarks/` 按用户路径组织门禁。它先构建 library 和 worker;被计时代码在纯 Node 下运行,不使用 TSX。合成输入执行耗时、堆和缩放预算;包内 `.perf.ts` 保留为诊断([规则](../.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md))。 - **快照**(`pnpm run test:snapshot`):顶层场景数值最高的已录制 parent generation 同时提供用户输入和模型回放,并作为持久化结果的预期值。parent 文件名是 `session[.vN].jsonl`;child 角色使用 `session.[.vN].jsonl`;v0 省略 `.v0`,正版本必须使用小写 `.vN`,且每个文件名必须与其 header 一致。进程级场景都通过 `dsh` 启动:headless 负责一次性行为,SDK 负责持久控制,ACP 负责自动化协议行为,Web 在同一 Session 旁保留浏览器与 ARIA 证据。`snapshot.yml` 声明 profile、组合与请求头类别、录制策略、例外回放或输入元数据以及 workspace 事实。带类型的 token 保留父子身份关系;只有请求头 pin 拥有 prompt/schema sidecar。变更 workspace 的场景会独立比较完整的 `workspace.expected/` 目录,record 与 refresh 绝不改写该目录。当模型 transcript(文本记录)变化时使用 `test:snapshot:record`,回放输入仍有效时使用 `test:snapshot:refresh`;请审查所有结果差异。 - **Web 浏览器快照**(`pnpm run test:web`;必需的 Linux PR(Pull Request)门禁):命令先构建插件 CSS,再用 Chromium 比较 `snapshots/web/` 下全部会话驱动输出和 `apps/web/tests/expected/` 下全部纯 UI 输出;模型与推理强度选择场景还在 WebKit 中运行。CI 强制只读的 `DSH_SNAPSHOT=replay`;record/refresh 留在本地,每处 diff 都须评审([web 车道](../.agents/notes/implemented/testing/2026-07-24-web-gui-browser-e2e-lane.zh.md)、[CI 说明](../scripts/run-web-snapshots.ts))。 diff --git a/package.json b/package.json index aa2aa84244..4fa191933d 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "check:ci:coverage-shard": "tsx scripts/run-gates.ts ci-coverage-shard", "check:ci:unit": "tsx scripts/run-gates.ts ci-unit", "check:ci:bench": "tsx scripts/run-gates.ts ci-bench", + "check:ci:bench-prebuilt": "tsx scripts/run-gates.ts ci-bench-prebuilt", "check:ci:snapshot": "tsx scripts/run-gates.ts ci-snapshot", "check:ci:artifacts": "tsx scripts/run-gates.ts ci-artifacts", "check:ci:consumers": "tsx scripts/run-gates.ts ci-consumers", diff --git a/scripts/bench-phase.ts b/scripts/bench-phase.ts new file mode 100644 index 0000000000..6f2d9f4a7d --- /dev/null +++ b/scripts/bench-phase.ts @@ -0,0 +1,21 @@ +/** + * Benchmark suite phases, kept free of build-tool imports so gate selection can + * validate a phase without loading the TypeScript compiler. + */ + +/** One phase of the suite: `first` runs the corpus cases, `last` runs the serial files of `run-bench-suite.ts`. */ +export type BenchPhase = 'first' | 'last' + +/** Which part of the report a phase invocation owns; `all` clears and renders on its own. */ +export type BenchReportPhase = BenchPhase | 'all' + +/** + * Parse a benchmark phase name. + * @param raw - the requested phase. + * @returns the phase. + * @throws If the value is not `first` or `last`. + */ +export function parseBenchPhase(raw: string | undefined): BenchPhase { + if (raw === 'first' || raw === 'last') return raw + throw new Error(`benchmark phase must be "first" or "last", got ${JSON.stringify(raw)}.`) +} diff --git a/scripts/ci-workflow.spec.ts b/scripts/ci-workflow.spec.ts index 0649ad7179..5c9cae1b98 100644 --- a/scripts/ci-workflow.spec.ts +++ b/scripts/ci-workflow.spec.ts @@ -15,7 +15,7 @@ const runnerPrivatePnpmDestination = /^\$\{\{ runner\.temp \}\}\/setup-pnpm-\$\{ const nativeWindowsPnpmDestination = '${{ runner.temp }}/setup-pnpm-js-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}' describe('CI workflow', () => { - it('keeps at most fifteen worker jobs active across PR workflows while Python runtime targets follow the SDK suite', () => { + it('keeps at most sixteen worker jobs active across PR workflows while Python runtime targets follow the SDK suite', () => { const ci = loadWorkflow('.github/workflows/ci.yml') const ciWindows = loadWorkflow('.github/workflows/ci-windows.yml') const ciPython = loadWorkflow('.github/workflows/ci-python.yml') @@ -58,8 +58,17 @@ describe('CI workflow', () => { const reportRunner = String(workflowJob(ci, 'node-24-coverage-report')['runs-on']) expect(reportRunner).toContain("'blacksmith-8vcpu-ubuntu-2404'") expect(reportRunner).toContain("'dsh-ubuntu-24-04-8core'") + // The two benchmark phases run as one matrix; their report job renders after them. + const bench = workflowJob(ci, 'node-24-bench') + expect(bench.strategy).toEqual({ + 'fail-fast': false, + matrix: { include: [{ shard: 1, phase: 'first' }, { shard: 2, phase: 'last' }] }, + }) + const benchPhases = isRecord(bench.strategy) && isRecord(bench.strategy.matrix) + && Array.isArray(bench.strategy.matrix.include) ? bench.strategy.matrix.include.length : 0 + expect(workflowJob(ci, 'node-24-bench-report').needs).toBe('node-24-bench') const ordinaryJobs = Object.entries(ci.jobs) - .filter(([name]) => !['node-compat', 'all-checks-passed', 'publisher-isolated', 'node-24-web-snapshot', 'node-24-coverage', 'node-24-coverage-report'].includes(name)) + .filter(([name]) => !['node-compat', 'all-checks-passed', 'publisher-isolated', 'node-24-web-snapshot', 'node-24-coverage', 'node-24-coverage-report', 'node-24-bench', 'node-24-bench-report'].includes(name)) for (const [name, job] of ordinaryJobs) { if (!isRecord(job)) throw new TypeError(`${name} must define a job`) expect(job).not.toHaveProperty('strategy') @@ -114,12 +123,13 @@ describe('CI workflow', () => { // self-hosted failover pool is still admitted only up to its own limit. // The build job finishes before its downstream jobs start, so the // static count overstates the peak by one. Coverage counts its two - // shards; the coverage report starts after them and is not counted. - const linuxActive = ordinaryJobs.length + webSnapshotShards + coverageLanes + // shards and the benchmarks their two phases; the coverage and benchmark + // report jobs start after them and are not counted. + const linuxActive = ordinaryJobs.length + webSnapshotShards + coverageLanes + benchPhases const beforeSdk = linuxActive + compatibilityLimit + windowsActive + 1 const afterSdk = linuxActive + compatibilityLimit + windowsActive + Math.max(1, targets.split(',').length) - expect(beforeSdk).toBeLessThanOrEqual(15) - expect(afterSdk).toBeLessThanOrEqual(15) + expect(beforeSdk).toBeLessThanOrEqual(16) + expect(afterSdk).toBeLessThanOrEqual(16) }) it('keeps required PR verdicts covering runtime and publisher jobs', () => { @@ -153,7 +163,10 @@ describe('CI workflow', () => { } } for (const id of workflowJob(ci, 'all-checks-passed').needs as string[]) visit(id) - expect(Object.keys(ci.jobs).filter(id => id !== 'all-checks-passed' && !covered.has(id))).toEqual([]) + // The benchmark report only renders results; node-24-bench owns the verdict. + const bookkeeping = ['all-checks-passed', 'node-24-bench-report'] + expect(Object.keys(ci.jobs).filter(id => !bookkeeping.includes(id) && !covered.has(id))).toEqual([]) + expect(blocking).not.toContain('node-24-bench-report') expect(blocking).not.toContain('node-24-coverage') // Every blocking lane must contribute to a branch-protection verdict. expect(blocking.sort()).toEqual([ @@ -667,8 +680,8 @@ describe('CI workflow', () => { // The benchmark lane is a required verdict input and runs alone so its // wall-clock budgets never share a runner with a concurrent aggregate. expect(aggregate.needs).toContain('node-24-bench') - expect(node24Bench.name).toBe('node 24 / benchmarks') - expect(node24Bench.env).toBeUndefined() + expect(node24Bench.name).toBe('node 24 / benchmarks ${{ matrix.shard }}/2') + expect(node24Bench.env).toEqual({ DSH_BENCH_PHASE: '${{ matrix.phase }}' }) expect(node24Bench.steps).toContainEqual({ name: 'Install benchmark browser and hosted dependencies', run: 'pnpm --filter @deepseek-ai/dsh-benchmarks exec playwright install --with-deps chromium', @@ -677,7 +690,7 @@ describe('CI workflow', () => { expect(node24Bench.steps).toContainEqual({ name: 'Run performance benchmarks', env: { DSH_GATE_VERBOSE: '1' }, - run: 'pnpm run check:ci:bench', + run: 'pnpm run check:ci:bench-prebuilt', }) expect(windowsAggregate.needs).not.toContain('serial-windows') @@ -808,10 +821,19 @@ describe('CI workflow', () => { } expect(JSON.stringify(benchmark.steps)).not.toContain('DSH_CI_FAILOVER_LINUX') expect(benchmark.if).toBe("github.event_name == 'pull_request'") - expect(benchmark.needs).toBeUndefined() + expect(benchmark.needs).toBe('node-24-build') expect(benchmark['continue-on-error']).toBeUndefined() - expect(benchmark.env).toBeUndefined() expect(aggregate.needs).toContain('node-24-bench') + + // The report job renders on a small hosted runner and installs nothing. + const report = workflowJob(workflow, 'node-24-bench-report') + expect(evaluateRunsOn(report['runs-on'], { vars: { DSH_CI_FAILOVER_LINUX: 'blacksmith' } })) + .toBe('blacksmith-2vcpu-ubuntu-2404') + for (const mode of ['', 'selfhosted', 'unexpected']) { + expect(evaluateRunsOn(report['runs-on'], { vars: { DSH_CI_FAILOVER_LINUX: mode } })).toBe('ubuntu-latest') + } + expect(report.if).toBe("${{ !cancelled() && github.event_name == 'pull_request' }}") + expect(JSON.stringify(report.steps)).not.toContain('pnpm install') }) it('always restores the hosted benchmark pnpm cache', () => { @@ -829,22 +851,57 @@ describe('CI workflow', () => { }) }) - it('bounds the complete benchmark job to twenty minutes', () => { + it('bounds each benchmark phase job to twenty minutes and runs it on the restored shared build', () => { const benchmark = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'node-24-bench') + if (!Array.isArray(benchmark.steps)) throw new TypeError('benchmark job must define steps') + const steps = benchmark.steps.filter(isRecord) + const index = (name: string): number => steps.findIndex(step => step.name === name) expect(benchmark['timeout-minutes']).toBe(20) expect(benchmark.steps).toContainEqual({ name: 'Run performance benchmarks', env: { DSH_GATE_VERBOSE: '1' }, - run: 'pnpm run check:ci:bench', + run: 'pnpm run check:ci:bench-prebuilt', }) + expect(steps[index('Download build output')]).toMatchObject({ uses: 'actions/download-artifact@v8.0.1', with: { name: 'build-output' } }) + expect(index('Download build output')).toBeGreaterThan(index('Install (immutable)')) + expect(index('Unpack build output')).toBeGreaterThan(index('Download build output')) + expect(index('Run performance benchmarks')).toBeGreaterThan(index('Unpack build output')) + expect(String(steps[index('Unpack build output')]?.run)).toContain('tar -xmf -') }) - it('publishes the scaled benchmark report even when a budget fails', () => { - const benchmark = workflowJob(loadWorkflow('.github/workflows/ci.yml'), 'node-24-bench') - if (!Array.isArray(benchmark.steps)) throw new TypeError('benchmark job must define steps') + it('uploads the results of each phase and publishes one scaled report even when a budget fails', () => { + const workflow = loadWorkflow('.github/workflows/ci.yml') + const benchmark = workflowJob(workflow, 'node-24-bench') + const report = workflowJob(workflow, 'node-24-bench-report') + if (!Array.isArray(benchmark.steps) || !Array.isArray(report.steps)) throw new TypeError('benchmark jobs must define steps') expect(benchmark.steps).toContainEqual({ + name: 'Upload benchmark results', + if: '${{ !cancelled() }}', + uses: 'actions/upload-artifact@v7.0.1', + with: { + name: 'benchmark-results-${{ matrix.shard }}', + path: 'benchmarks/.dsh-report/', + 'include-hidden-files': true, + 'if-no-files-found': 'warn', + 'retention-days': 7, + overwrite: true, + }, + }) + const uploadIndex = benchmark.steps.findIndex(step => isRecord(step) && step.name === 'Upload benchmark results') + const benchmarkIndex = benchmark.steps.findIndex(step => isRecord(step) && step.name === 'Run performance benchmarks') + expect(uploadIndex).toBeGreaterThan(benchmarkIndex) + + const steps = report.steps.filter(isRecord) + const download = steps.findIndex(step => step.name === 'Download benchmark results') + const render = steps.findIndex(step => step.name === 'Render scaled benchmark report') + const publish = steps.findIndex(step => step.name === 'Upload scaled benchmark report') + expect(steps[download]).toMatchObject({ with: { pattern: 'benchmark-results-*' } }) + expect(String(steps[render]?.run)).toContain('node scripts/render-benchmark-report.ts benchmarks/.dsh-report') + expect(render).toBeGreaterThan(download) + expect(publish).toBeGreaterThan(render) + expect(steps[publish]).toEqual({ name: 'Upload scaled benchmark report', if: '${{ !cancelled() }}', uses: 'actions/upload-artifact@v7.0.1', @@ -856,10 +913,6 @@ describe('CI workflow', () => { 'retention-days': 7, }, }) - - const uploadIndex = benchmark.steps.findIndex(step => isRecord(step) && step.name === 'Upload scaled benchmark report') - const benchmarkIndex = benchmark.steps.findIndex(step => isRecord(step) && step.name === 'Run performance benchmarks') - expect(uploadIndex).toBeGreaterThan(benchmarkIndex) }) it('splits both Wine TypeScript faces and retains their aggregate heap budgets', () => { diff --git a/scripts/render-benchmark-report.spec.ts b/scripts/render-benchmark-report.spec.ts new file mode 100644 index 0000000000..767b8559fa --- /dev/null +++ b/scripts/render-benchmark-report.spec.ts @@ -0,0 +1,80 @@ +import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { afterEach, describe, expect, it } from 'vitest' +import { mergeReportDirectories, renderMergedReport } from '../benchmarks/support/scaling-report.ts' + +const roots: string[] = [] +afterEach(async () => { + for (const root of roots.splice(0)) await rm(root, { recursive: true, force: true }) +}) + +async function temporaryRoot(): Promise { + const root = await mkdtemp(join(tmpdir(), 'dsh-benchmark-report-')) + roots.push(root) + return root +} + +const machine = { cpuModel: 'AMD EPYC 9454P', platform: 'linux-x64', node: 'v24.12.0', cores: 4, measuredProfile: 'ci-4' } + +/** Write one phase report directory as a benchmark job uploads it. */ +async function writePhase(root: string, name: string, benchmarks: readonly string[], environment: object = machine): Promise { + const directory = join(root, name) + await mkdir(directory, { recursive: true }) + const records = benchmarks.map(benchmark => ({ kind: 'time', benchmark, measures: 'm', affects: 'a', metric: 'ms', ms: 10, cpuMs: 9 })) + await writeFile(join(directory, 'results.jsonl'), records.map(record => JSON.stringify(record) + '\n').join('')) + await writeFile(join(directory, 'environment.json'), JSON.stringify(environment)) + return directory +} + +describe('merged benchmark report', () => { + it('concatenates the phase records and keeps the shared measuring machine', async () => { + const root = await temporaryRoot() + const first = await writePhase(root, 'benchmark-results-1', ['session-corpus/list']) + const last = await writePhase(root, 'benchmark-results-2', ['user-text/paste', 'session-open/first-open']) + + const { data, warnings } = mergeReportDirectories([first, last], 'abc123', '2026-11-20T00:00:00.000Z') + + expect(data.records.map(record => record.benchmark)).toEqual(['session-corpus/list', 'user-text/paste', 'session-open/first-open']) + expect(data).toMatchObject({ ...machine, revision: 'abc123', generatedAt: '2026-11-20T00:00:00.000Z' }) + expect(warnings).toEqual([]) + }) + + it('lists both CPUs and leaves the measured profile to the reader when the phases ran on different machines', async () => { + const root = await temporaryRoot() + const first = await writePhase(root, 'benchmark-results-1', ['a']) + const last = await writePhase(root, 'benchmark-results-2', ['b'], { ...machine, cpuModel: 'Intel Xeon 8375C', measuredProfile: 'other' }) + + const { data, warnings } = mergeReportDirectories([first, last], undefined, 'now') + + expect(data.cpuModel).toBe('AMD EPYC 9454P | Intel Xeon 8375C') + expect(data.measuredProfile).toBeUndefined() + expect(warnings).toHaveLength(1) + }) + + it('skips a phase that recorded nothing and refuses when no phase did', async () => { + const root = await temporaryRoot() + const first = await writePhase(root, 'benchmark-results-1', ['a']) + const empty = join(root, 'benchmark-results-2') + await mkdir(empty) + + expect(mergeReportDirectories([first, empty], undefined, 'now').data.records).toHaveLength(1) + expect(() => mergeReportDirectories([empty], undefined, 'now')).toThrow(/no benchmark results/) + }) + + it('refuses results without a valid measuring environment', async () => { + const root = await temporaryRoot() + const phase = await writePhase(root, 'benchmark-results-1', ['a'], { cpuModel: 'x', cores: 0 }) + + expect(() => mergeReportDirectories([phase], undefined, 'now')).toThrow(/must record cpuModel/) + }) + + it('writes one report page into the output directory', async () => { + const root = await temporaryRoot() + const phase = await writePhase(root, 'benchmark-results-1', ['session-corpus/list']) + const output = join(root, 'report') + + expect(renderMergedReport(output, [phase])).toEqual([]) + expect(await readFile(join(output, 'report.html'), 'utf8')).toContain('session-corpus/list') + }) +}) diff --git a/scripts/render-benchmark-report.ts b/scripts/render-benchmark-report.ts new file mode 100644 index 0000000000..01d48e8152 --- /dev/null +++ b/scripts/render-benchmark-report.ts @@ -0,0 +1,14 @@ +/** + * Render one scaled benchmark report from the report directories of benchmark phases that ran on separate + * runners. Usage: `node scripts/render-benchmark-report.ts ...`. + * Runs under plain Node type stripping, so the CI report job needs no dependency install. + */ +import { resolve } from 'node:path' +import { renderMergedReport } from '../benchmarks/support/scaling-report.ts' + +const [output, ...inputs] = process.argv.slice(2) +if (output === undefined || inputs.length === 0) { + throw new Error('usage: node scripts/render-benchmark-report.ts ...') +} +for (const warning of renderMergedReport(resolve(output), inputs.map(input => resolve(input)))) console.warn(warning) +console.log(`benchmark report: ${resolve(output, 'report.html')}`) diff --git a/scripts/run-bench-suite.ts b/scripts/run-bench-suite.ts index d684e2bdb1..15664feea1 100644 --- a/scripts/run-bench-suite.ts +++ b/scripts/run-bench-suite.ts @@ -1,5 +1,6 @@ /** Run the benchmark suite in the two phases its measurements tolerate. */ import { resolve } from 'node:path' +import type { BenchPhase, BenchReportPhase } from './bench-phase.ts' import { runPnpmCommand } from './compile-referenced-projects.ts' /** @@ -26,12 +27,14 @@ const CONFIG = ['--config', 'vitest.bench.config.ts'] as const /** * Run one phase of the suite. * @param root - Repository root containing the Vitest configuration. - * @param phase - `first` clears the report and runs the CPU cases two at a time; - * `last` runs the browser cases one at a time and renders the report. + * @param phase - `first` runs the CPU cases two at a time; `last` runs the + * browser cases one at a time. + * @param reportPhase - report ownership: by default `first` clears the report and + * `last` renders it; `all` lets a phase that runs alone on its runner do both. * @throws If the phase fails. */ -export function runBenchPhase(root: string, phase: 'first' | 'last'): void { - process.env.DSH_BENCH_REPORT_PHASE = phase +export function runBenchPhase(root: string, phase: BenchPhase, reportPhase: BenchReportPhase = phase): void { + process.env.DSH_BENCH_REPORT_PHASE = reportPhase try { if (phase === 'first') { runPnpmCommand(root, [ diff --git a/scripts/run-ci-bench.ts b/scripts/run-ci-bench.ts index c4778982e1..9d71987b92 100644 --- a/scripts/run-ci-bench.ts +++ b/scripts/run-ci-bench.ts @@ -1,7 +1,15 @@ -/** Build benchmark artifacts with TypeScript diagnostics owned by required full builds. */ +/** + * Build benchmark artifacts with TypeScript diagnostics owned by required full builds, then run the suite. + * `--phase first|last` instead runs one phase on restored shared-build output after building only the + * benchmark workers. + */ import { resolve } from 'node:path' +import { parseArgs } from 'node:util' import { buildLibraryArtifacts, runPnpmCommand } from './compile-referenced-projects.ts' +import { parseBenchPhase } from './bench-phase.ts' +import type { BenchPhase } from './bench-phase.ts' +import { runBenchPhase } from './run-bench-suite.ts' /** * Build native support, libraries, benchmark workers, and Web assets that benchmark files consume. @@ -11,10 +19,32 @@ import { buildLibraryArtifacts, runPnpmCommand } from './compile-referenced-proj export function buildCiBenchArtifacts(root: string): void { runPnpmCommand(root, ['run', 'build:native-system']) buildLibraryArtifacts(root, false, 'benchmark-emit') - runPnpmCommand(root, ['exec', 'tsdown', '--config-loader', 'native', '--config', 'benchmarks/tsdown.config.ts']) + buildBenchWorkers(root) runPnpmCommand(root, ['run', 'build:web']) } +/** + * Build the `benchmarks/.dsh-build/` workers, the only output the shared CI build does not emit. + * @param root - Repository root containing the benchmark bundle configuration. + * @throws If the bundle fails. + */ +export function buildBenchWorkers(root: string): void { + runPnpmCommand(root, ['exec', 'tsdown', '--config-loader', 'native', '--config', 'benchmarks/tsdown.config.ts']) +} + +/** + * Run one suite phase on a checkout whose libraries, native addon, and Web + * assets were restored from the shared CI build. The phase runs alone on its + * runner, so it clears and renders its own report results. + * @param root - Repository root containing the restored build output. + * @param phase - the phase to run. + * @throws If the worker build or the phase fails. + */ +export function runCiBenchPhase(root: string, phase: BenchPhase): void { + buildBenchWorkers(root) + runBenchPhase(root, phase, 'all') +} + /** * Build benchmark artifacts, then run the existing benchmark suite. * @param root - Repository root containing all build configurations. @@ -25,4 +55,9 @@ export function runCiBench(root: string): void { runPnpmCommand(root, ['run', 'test:bench:built']) } -if (import.meta.main) runCiBench(resolve(import.meta.dirname, '..')) +if (import.meta.main) { + const { values } = parseArgs({ options: { phase: { type: 'string' } }, allowPositionals: false }) + const root = resolve(import.meta.dirname, '..') + if (values.phase === undefined) runCiBench(root) + else runCiBenchPhase(root, parseBenchPhase(values.phase)) +} diff --git a/scripts/run-gates.spec.ts b/scripts/run-gates.spec.ts index 80736e7bfd..c5f6bdc5e2 100644 --- a/scripts/run-gates.spec.ts +++ b/scripts/run-gates.spec.ts @@ -26,6 +26,7 @@ import { beforeEach(() => { vi.stubEnv('DSH_WEB_SNAPSHOT_WORKERS', undefined) vi.stubEnv('DSH_COVERAGE_SHARD', undefined) + vi.stubEnv('DSH_BENCH_PHASE', undefined) vi.stubEnv('DSH_COVERAGE_MAX_WORKERS', undefined) vi.stubEnv('DSH_COVERAGE_PARTITIONS', undefined) vi.stubEnv('DSH_CLI_HELP_CONCURRENCY', undefined) @@ -295,6 +296,26 @@ describe('gate graph validation', () => { expect(scripts['test:bench:built']).toBe('tsx scripts/run-bench-suite.ts') }) + it.each(['first', 'last'] as const)('runs the %s benchmark phase on restored shared-build output', (phase) => { + const subject = withEnv('DSH_BENCH_PHASE', phase, () => withPnpmEntrypoint(() => gatesForMode('ci-bench-prebuilt'))) + const { scripts } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { + scripts: Record + } + + expect(scripts['check:ci:bench-prebuilt']).toBe('tsx scripts/run-gates.ts ci-bench-prebuilt') + expect(subject).toHaveLength(1) + expect(subject[0]).toMatchObject({ + id: 'bench', + label: `performance benchmarks (${phase} phase)`, + args: ['/private/pnpm.cjs', 'exec', 'tsx', 'scripts/run-ci-bench.ts', `--phase=${phase}`], + }) + }) + + it.each([undefined, '', 'all', 'second'])('refuses benchmark phase %j', (raw) => { + expect(() => withEnv('DSH_BENCH_PHASE', raw, () => withPnpmEntrypoint(() => gatesForMode('ci-bench-prebuilt')))) + .toThrow('benchmark phase must be "first" or "last"') + }) + it('checks all maintained repository references locally and in CI', () => { const { scripts } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { scripts: Record diff --git a/scripts/run-gates.ts b/scripts/run-gates.ts index 79992b49d6..8ac550832c 100644 --- a/scripts/run-gates.ts +++ b/scripts/run-gates.ts @@ -9,6 +9,7 @@ import { readdirSync, readFileSync } from 'node:fs' import { availableParallelism } from 'node:os' import { resolve } from 'node:path' import { performance } from 'node:perf_hooks' +import { parseBenchPhase } from './bench-phase.ts' import { CLIENT_BUILD_PROFILE_SELECTOR } from './client-build-environment.ts' import { COVERAGE_EXEMPT_ENV, coverageExemptHeavySuites } from './coverage-exempt.ts' import { COVERAGE_PARTITIONS_ENV, COVERAGE_SHARD_ENV, parseCoveragePartitionCount, parseCoverageShard } from './coverage-partitions.ts' @@ -25,6 +26,7 @@ export type Mode = | 'ci-coverage-shard' | 'ci-unit' | 'ci-bench' + | 'ci-bench-prebuilt' | 'ci-snapshot' | 'ci-artifacts' | 'ci-consumers' @@ -169,6 +171,7 @@ function parseMode(raw: string | undefined): Mode { case 'ci-coverage-shard': case 'ci-unit': case 'ci-bench': + case 'ci-bench-prebuilt': case 'ci-snapshot': case 'ci-artifacts': case 'ci-consumers': @@ -187,7 +190,7 @@ function parseMode(raw: string | undefined): Mode { return raw default: throw new Error( - `run-gates: expected mode ci-primary | ci-linux-primary | ci-static | ci-lint-contracts-ready | ci-coverage | ci-coverage-shard | ci-unit | ci-bench | ci-snapshot | ci-artifacts | ci-consumers | ci-build | ci-consumers-prebuilt | ci-web-snapshot-prebuilt | ci-windows-blocking | ci-windows-complete | ci-windows-observational-ready | node-compat | check-all | hygiene | doc-sync | doc-quick | i18n, got ${JSON.stringify(raw)}.`, + `run-gates: expected mode ci-primary | ci-linux-primary | ci-static | ci-lint-contracts-ready | ci-coverage | ci-coverage-shard | ci-unit | ci-bench | ci-bench-prebuilt | ci-snapshot | ci-artifacts | ci-consumers | ci-build | ci-consumers-prebuilt | ci-web-snapshot-prebuilt | ci-windows-blocking | ci-windows-complete | ci-windows-observational-ready | node-compat | check-all | hygiene | doc-sync | doc-quick | i18n, got ${JSON.stringify(raw)}.`, ) } } @@ -341,6 +344,8 @@ export function gatesForMode(selected: Mode): Gate[] { return ciUnitGates() case 'ci-bench': return [pnpmExec('bench', ['tsx', 'scripts/run-ci-bench.ts'], { label: 'performance benchmarks' })] + case 'ci-bench-prebuilt': + return ciBenchPrebuiltGates() case 'ci-snapshot': return [ciBuildGate(), snapshotGate()] case 'ci-artifacts': @@ -669,6 +674,17 @@ function ciPrebuiltWebSnapshotGates(): Gate[] { return [webSnapshotGate([])] } +/** + * One benchmark phase (`DSH_BENCH_PHASE`) on a checkout whose build output was + * restored from the `ci-build` lane; only the benchmark workers are built here. + */ +function ciBenchPrebuiltGates(): Gate[] { + const phase = parseBenchPhase(process.env.DSH_BENCH_PHASE) + return [pnpmExec('bench', ['tsx', 'scripts/run-ci-bench.ts', `--phase=${phase}`], { + label: `performance benchmarks (${phase} phase)`, + })] +} + function webSnapshotGate(needs: string[], after?: string[]): Gate { const order = after === undefined ? { needs } : { needs, after } const workerRaw = process.env.DSH_WEB_SNAPSHOT_WORKERS