Просмотр исходного кода

feat: trigger full performance checks with a PR label

saladday 2 месяцев назад
Родитель
Сommit
59530de4f1

+ 10 - 0
.agents/skills/testing-workflow/SKILL.md

@@ -69,6 +69,16 @@ does not replace source validation. The release command commits matching root/TU
 The release workflow rejects version mismatches and runs the full profile before
 The release workflow rejects version mismatches and runs the full profile before
 package installation checks.
 package installation checks.
 
 
+## Performance coverage
+
+Use [CONTRIBUTING.md](../../../CONTRIBUTING.md#performance-checks) to classify the
+change. Add `perf:full` for performance optimizations, changes to history/token
+processing, storage, streaming or tool execution, and large runtime refactors.
+The label automatically selects the full suite and keeps it selected for later
+commits. Before merge, link a passing `performance` run with `Suite: full` for the
+latest head and intended base. Read [Performance CI](../../../docs/performance-ci.md)
+for evidence, limits and manual dispatch.
+
 ## Manual evidence and reporting
 ## Manual evidence and reporting
 
 
 For CLI behavior, exercise the built `dist/cli.js` and inspect stdout, stderr and
 For CLI behavior, exercise the built `dist/cli.js` and inspect stdout, stderr and

+ 1 - 0
.github/PULL_REQUEST_TEMPLATE.md

@@ -7,6 +7,7 @@ Describe the user-visible problem and resulting behavior. Link a public issue wh
 ## Validation
 ## Validation
 
 
 - Checks run and results (include the revision/profile where relevant):
 - Checks run and results (include the revision/profile where relevant):
+- Performance: basic / `perf:full` (see [requirements](https://github.com/MiniMax-AI/minimax-code/blob/main/CONTRIBUTING.md#performance-checks)); for full coverage, link a passing run for the latest PR head and intended base:
 - NOT RUN, platform limitations and live-service boundaries:
 - NOT RUN, platform limitations and live-service boundaries:
 
 
 ## Publication and contribution checks
 ## Publication and contribution checks

+ 13 - 7
.github/workflows/performance.yml

@@ -1,6 +1,7 @@
 name: Performance
 name: Performance
 on:
 on:
   pull_request:
   pull_request:
+    types: [opened, synchronize, reopened, labeled, unlabeled]
   workflow_dispatch:
   workflow_dispatch:
     inputs:
     inputs:
       base:
       base:
@@ -16,14 +17,19 @@ on:
         options: [full, basic]
         options: [full, basic]
 permissions:
 permissions:
   contents: read
   contents: read
-concurrency:
-  group: performance-${{ github.event_name }}-${{ inputs.suite || 'basic' }}-${{ github.ref }}
-  cancel-in-progress: true
 jobs:
 jobs:
   performance:
   performance:
-    name: performance (${{ inputs.suite || 'basic' }})
+    # Unrelated label events must not replace the actual performance check.
+    name: ${{ contains(fromJSON('["labeled","unlabeled"]'), github.event.action) && github.event.label.name != 'perf:full' && 'performance (label ignored)' || 'performance' }}
+    if: ${{ !contains(fromJSON('["labeled","unlabeled"]'), github.event.action) || github.event.label.name == 'perf:full' }}
+    strategy:
+      matrix:
+        suite: ${{ fromJSON((inputs.suite == 'full' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'perf:full'))) && '["full"]' || '["basic"]') }}
+    concurrency:
+      group: performance-${{ github.event_name }}-${{ github.ref }}-${{ github.event_name == 'workflow_dispatch' && matrix.suite || 'auto' }}
+      cancel-in-progress: true
     runs-on: macos-15
     runs-on: macos-15
-    timeout-minutes: ${{ inputs.suite == 'full' && 45 || 15 }}
+    timeout-minutes: ${{ matrix.suite == 'full' && 45 || 15 }}
     steps:
     steps:
       - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
       - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
         with:
         with:
@@ -67,13 +73,13 @@ jobs:
         run: bun install --frozen-lockfile
         run: bun install --frozen-lockfile
       - name: Compare on this runner
       - name: Compare on this runner
         env:
         env:
-          PERF_SUITE: ${{ inputs.suite || 'basic' }}
+          PERF_SUITE: ${{ matrix.suite }}
         run: node candidate/scripts/perf/run.mjs --base baseline --head candidate --benchmark benchmark --suite "$PERF_SUITE" --out "$RUNNER_TEMP/performance"
         run: node candidate/scripts/perf/run.mjs --base baseline --head candidate --benchmark benchmark --suite "$PERF_SUITE" --out "$RUNNER_TEMP/performance"
       - name: Upload performance evidence
       - name: Upload performance evidence
         if: ${{ always() }}
         if: ${{ always() }}
         uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
         uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
         with:
         with:
-          name: performance-${{ inputs.suite || 'basic' }}-${{ github.run_attempt }}
+          name: performance-${{ matrix.suite }}-${{ github.run_attempt }}
           path: ${{ runner.temp }}/performance/
           path: ${{ runner.temp }}/performance/
           include-hidden-files: true
           include-hidden-files: true
           retention-days: 14
           retention-days: 14

+ 26 - 1
CONTRIBUTING.md

@@ -55,7 +55,32 @@ Test files are declared in `test/vitest-suites.json`, grouped by the gate that r
 
 
 Review added or removed files before running `node scripts/source-inventory.mjs --write`. Updating the inventory must not bypass checks for private protocols, internal addresses, credentials, or third-party licensing. Before a source release, also scan the complete Git history with Gitleaks; see the [release process](docs/releasing.md).
 Review added or removed files before running `node scripts/source-inventory.mjs --write`. Updating the inventory must not bypass checks for private protocols, internal addresses, credentials, or third-party licensing. Before a source release, also scan the complete Git history with Gitleaks; see the [release process](docs/releasing.md).
 
 
-PRs also run the [performance comparison](docs/performance-ci.md): the pinned 100-round upstream benchmark automatically, with startup and long-history fixtures available through the manual full suite. Both compare base/head on the same runner. Raw evidence and machine configuration accompany the check.
+## Performance checks
+
+Every PR runs the pinned 100-round upstream benchmark. Add the `perf:full` label
+for the changes below; it automatically selects startup, 100-round and 300-round
+long-history tests instead. Keep the label until merge so new commits run the
+full suite too.
+
+| Change | Required performance coverage |
+| --- | --- |
+| Performance optimization, including CPU, memory, startup or throughput fixes | `perf:full` |
+| History construction/serialization, token estimation/caching, session storage, streaming or the tool execution loop | `perf:full` |
+| Large runtime refactors spanning multiple components, or runtime dependency changes affecting these paths | `perf:full` |
+| Other changes, including documentation-only edits and mechanical changes outside runtime paths | Automatic 100-round basic check |
+
+The author adds the label; reviewers verify the classification. File count alone
+does not make a change a large runtime refactor. Before merging a labeled PR,
+require a successful `performance` check with `Suite: full` for the latest PR
+head and intended base, and link the run in the PR's Validation section. Failed,
+cancelled or inconclusive runs do not satisfy this requirement. If the base
+changes after measurement, rerun against the updated base.
+
+Removing `perf:full` restores the basic suite; do not remove it to bypass a
+failure. Unrelated label changes do not run benchmarks. This is a review rule;
+repository administrators must configure required checks separately. See
+[Performance CI](docs/performance-ci.md) for manual dispatch, runner configuration
+and raw evidence.
 
 
 ## Capability boundaries
 ## Capability boundaries
 
 

+ 11 - 5
docs/performance-ci.md

@@ -1,14 +1,17 @@
 # Performance CI
 # Performance CI
 
 
-Every PR automatically runs `performance (basic)`: only the original 100-round
-scenario. Performance optimization PRs can run the full suite manually. Both
+Every PR runs the `performance` check: the original 100-round scenario by default.
+Adding `perf:full` automatically runs the full suite. While the label remains,
+new commits and reopened PRs run the full suite too. Removing it starts a basic
+run and cancels any previous automatic run for that PR. Unrelated label changes
+skip benchmarking under a separate `performance (label ignored)` check. Both
 revisions build separately, then run serially on one `macos-15` runner with Node
 revisions build separately, then run serially on one `macos-15` runner with Node
 22.23.2 and Bun 1.4.2. Build and installation time are excluded.
 22.23.2 and Bun 1.4.2. Build and installation time are excluded.
 
 
 | Mode | Trigger | Scenarios | Job timeout |
 | Mode | Trigger | Scenarios | Job timeout |
 | --- | --- | --- | --- |
 | --- | --- | --- | --- |
-| `basic` | Every PR; optional manual run | `upstream-100` | 15 minutes |
-| `full` | Manual only | Startup, `upstream-100`, `history-300` | 45 minutes |
+| `basic` | PR without `perf:full`; optional manual run | `upstream-100` | 15 minutes |
+| `full` | Add `perf:full`, then new commits/reopens while labeled; optional manual run | Startup, `upstream-100`, `history-300` | 45 minutes |
 
 
 | Scenario | Input | Purpose |
 | Scenario | Input | Purpose |
 | --- | --- | --- |
 | --- | --- | --- |
@@ -48,7 +51,10 @@ needs another clean measurement; it is neither a confirmed regression nor a pass
 Tune budgets from repeated same-revision measurements. Review changes to
 Tune budgets from repeated same-revision measurements. Review changes to
 scenarios, comparison logic or limits as changes to the performance contract.
 scenarios, comparison logic or limits as changes to the performance contract.
 The workflow does not change branch protection; maintainers can add
 The workflow does not change branch protection; maintainers can add
-`performance (basic)` as a required check after runner calibration.
+`performance` as a required check after runner calibration; its name stays the
+same for basic and full runs. The summary and artifact identify the selected
+suite. Follow the [label and review requirements](../CONTRIBUTING.md#performance-checks)
+when deciding which PRs need full coverage.
 
 
 The Job Summary contains machine/method and comparison tables. The 14-day
 The Job Summary contains machine/method and comparison tables. The 14-day
 artifact includes JSON results, configuration, commit and fixture hashes,
 artifact includes JSON results, configuration, commit and fixture hashes,

+ 14 - 1
test/source-sync.test.mjs

@@ -31,10 +31,23 @@ test('performance defaults to the 100-round suite; long history requires explici
   assert.equal(workflow.on.workflow_dispatch.inputs.suite.default, 'full');
   assert.equal(workflow.on.workflow_dispatch.inputs.suite.default, 'full');
   assert.deepEqual(workflow.on.workflow_dispatch.inputs.suite.options, ['full', 'basic']);
   assert.deepEqual(workflow.on.workflow_dispatch.inputs.suite.options, ['full', 'basic']);
   const compare = workflow.jobs.performance.steps.find(s => s.name === 'Compare on this runner');
   const compare = workflow.jobs.performance.steps.find(s => s.name === 'Compare on this runner');
-  assert.equal(compare.env.PERF_SUITE, "${{ inputs.suite || 'basic' }}");
+  assert.equal(compare.env.PERF_SUITE, "${{ matrix.suite }}");
   assert.match(compare.run, /--suite "\$PERF_SUITE"/);
   assert.match(compare.run, /--suite "\$PERF_SUITE"/);
 });
 });
 
 
+test('performance labels select full coverage without interrupting checks for unrelated labels', () => {
+  const workflow = parseYaml(readFileSync(new URL('../.github/workflows/performance.yml', import.meta.url), 'utf8'));
+  const job = workflow.jobs.performance;
+  assert.deepEqual(workflow.on.pull_request.types, ['opened', 'synchronize', 'reopened', 'labeled', 'unlabeled']);
+  assert.equal(job.strategy.matrix.suite, `\${{ fromJSON((inputs.suite == 'full' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'perf:full'))) && '["full"]' || '["basic"]') }}`);
+  assert.equal(job.if, `\${{ !contains(fromJSON('["labeled","unlabeled"]'), github.event.action) || github.event.label.name == 'perf:full' }}`);
+  assert.equal(job.name, `\${{ contains(fromJSON('["labeled","unlabeled"]'), github.event.action) && github.event.label.name != 'perf:full' && 'performance (label ignored)' || 'performance' }}`);
+  assert.equal(workflow.concurrency, undefined);
+  assert.equal(job.concurrency.group, `performance-\${{ github.event_name }}-\${{ github.ref }}-\${{ github.event_name == 'workflow_dispatch' && matrix.suite || 'auto' }}`);
+  assert.equal(job.concurrency['cancel-in-progress'], true);
+  assert.equal(job['timeout-minutes'], `\${{ matrix.suite == 'full' && 45 || 15 }}`);
+});
+
 test('performance request audit rejects truncated wire history and empty tool results', () => {
 test('performance request audit rejects truncated wire history and empty tool results', () => {
   const responses = [
   const responses = [
     { message: { content: 'full history', tool_calls: [{ id: 'call_long_run_1', function: { name: 'bash', arguments: { command: 'ls' } } }] } },
     { message: { content: 'full history', tool_calls: [{ id: 'call_long_run_1', function: { name: 'bash', arguments: { command: 'ls' } } }] } },