Skip to content

perf(core): optimize updateTestModes traversal#1202

Merged
9aoy merged 2 commits into
mainfrom
perf/update-test-modes-traversal
Apr 23, 2026
Merged

perf(core): optimize updateTestModes traversal#1202
9aoy merged 2 commits into
mainfrom
perf/update-test-modes-traversal

Conversation

@9aoy

@9aoy 9aoy commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Background

updateTestModes was repeatedly rescanning suite subtrees for only handling and rebuilding name-match work per test, which showed up in synthetic runner benchmarks.

Implementation

  • Precompute whether each suite has only descendants with a WeakMap, then reuse that state during the run-mode traversal.
  • Collapse suite status aggregation into the main traversal loop and reuse a single testNamePattern matcher;

User Impact

Large collected test trees spend less time normalizing run modes before execution; no user-facing API changes.

Benchmark

describe('synthetic rstest suite', () => {
  for (let i = 0; i < 10000; i++) {
    it('adds numbers ' + i, () => {
      expect(1 + 1).toBe(2);
    });
  }
});

Result:

  • Before: 681ms (build 78ms, tests 603ms), wall clock real 1.53s
  • After: 562ms (build 70ms, tests 492ms), wall clock real 1.21s

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 12 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 2.2 KB 0
adapter-rslib 23.2 KB 0
adapter-rspack 5.9 KB 0
browser 2.0 MB 0
browser-react 3.7 KB 0
browser-ui 802.9 KB 0
coverage-istanbul 9.6 KB 0
core/browser 966.1 KB +844.0 B (0.1%)
core/loaders 869.0 B 0
core/main 1.6 MB +844.0 B (0.1%)
vscode/extension 60.3 MB 0
vscode/worker 14.4 KB 0
📋 Detailed Reports (Click to expand)

📁 core/browser

Path: packages/core/.rsdoctor/browser/rsdoctor-data.json

📌 Baseline Commit: 75ce306725 | PR: #1200

Metric Current Baseline Change
📊 Total Size 966.1 KB 965.2 KB +844.0 B (0.1%)
📄 JavaScript 957.9 KB 957.1 KB +844.0 B (0.1%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 8.1 KB 8.1 KB 0

📦 Download Diff Report: core/browser Bundle Diff

📁 core/main

Path: packages/core/.rsdoctor/main/rsdoctor-data.json

📌 Baseline Commit: 75ce306725 | PR: #1200

Metric Current Baseline Change
📊 Total Size 1.6 MB 1.6 MB +844.0 B (0.1%)
📄 JavaScript 1.5 MB 1.5 MB +844.0 B (0.1%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 79.2 KB 79.2 KB 0

📦 Download Diff Report: core/main Bundle Diff

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 1 untouched benchmark
⏩ 3 skipped benchmarks1


Comparing perf/update-test-modes-traversal (4fffa59) with main (75ce306)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@9aoy 9aoy marked this pull request as ready for review April 23, 2026 09:35
@9aoy 9aoy requested a review from Copilot April 23, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the core runner’s updateTestModes normalization pass by avoiding repeated subtree scans for only propagation and by reusing precomputed name-pattern matching state.

Changes:

  • Precomputes “suite has only descendants” using a WeakMap (collectOnlyTests) and reuses it during traversal.
  • Refactors traversal into a context-based implementation (traverseUpdateTestRunModeWithContext) to reuse shared state, including a single name-pattern predicate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/runtime/runner/task.ts Outdated
@9aoy

9aoy commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@9aoy 9aoy merged commit 786bf05 into main Apr 23, 2026
21 checks passed
@9aoy 9aoy deleted the perf/update-test-modes-traversal branch April 23, 2026 10:37
@fi3ework fi3ework mentioned this pull request Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants