Skip to content

ci: add pull request benchmarks#45

Merged
ScriptedAlchemy merged 5 commits into
mainfrom
codex/pr-benchmark-ci
Jun 21, 2026
Merged

ci: add pull request benchmarks#45
ScriptedAlchemy merged 5 commits into
mainfrom
codex/pr-benchmark-ci

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

Summary

  • add a pull_request benchmark workflow that compares PR head against the PR base commit
  • upload raw benchmark artifacts, generate a sticky PR comment, and persist report data to a benchmark-results branch for cross-PR history
  • add reusable benchmark scripts and documentation for local smoke/default/full runs

Notes

  • The workflow runs the PR benchmark script against both checkouts, so this first PR can benchmark the current main commit even though main does not have the harness yet.
  • Benchmark history is written under pull-requests/// on the benchmark-results branch when the PR branch is in this repository.

Validation

  • pnpm install --frozen-lockfile
  • pnpm bench:smoke
  • node scripts/report-benchmark-ci.mjs --base .benchmark/results/smoke/baseline.json --head .benchmark/results/smoke/baseline.json --out .benchmark/results/smoke-report --pr 0 --base-ref main --base-sha 0b2b552 --head-ref codex/pr-benchmark-ci --head-sha $(git rev-parse HEAD) --run-url https://example.invalid
  • local smoke of origin/main using the PR benchmark script and benchmark-only React plugin import path
  • pnpm build
  • pnpm test:core
  • pnpm exec prettier --check .github/workflows/benchmark.yml scripts/bench-builds.mjs scripts/benchmark/fixture.mjs scripts/compare-benchmarks.mjs scripts/report-benchmark-ci.mjs benchmarks/README.md package.json
  • go run github.com/rhysd/actionlint/cmd/actionlint@latest .github/workflows/benchmark.yml
  • git diff --check

@pkg-pr-new

pkg-pr-new Bot commented Jun 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@e8dbc7e

commit: e8dbc7e

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review June 21, 2026 00:12
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Compared PR head e8dbc7e against base 0b2b552.

Total median wall time: 19.70s -> 19.58s (-0.6%, 1.01x speedup)

Benchmark Base Head Delta Speedup Head RSS p95
synthetic-256-sourcemaps 3.40s 3.42s +0.8% 0.99x 523 MB
synthetic-256-spa 8.31s 8.28s -0.4% 1.00x 509 MB
synthetic-256-ssr-esm 3.42s 3.35s -2.3% 1.02x 507 MB
synthetic-256-ssr-esm-split 4.57s 4.53s -0.9% 1.01x 723 MB

Profile: default; iterations: 5; warmup: 1.
Workflow run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 000435904e

ℹ️ 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".

Comment thread .github/workflows/benchmark.yml
Comment thread scripts/benchmark/fixture.mjs Outdated
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ScriptedAlchemy, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 15 minutes and 4 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cf28ed35-151f-4fd1-9c2a-bf02ef8be016

📥 Commits

Reviewing files that changed from the base of the PR and between 0004359 and e8dbc7e.

📒 Files selected for processing (6)
  • .github/workflows/benchmark.yml
  • benchmarks/README.md
  • scripts/bench-builds.mjs
  • scripts/benchmark/fixture.mjs
  • scripts/compare-benchmarks.mjs
  • scripts/report-benchmark-ci.mjs
📝 Walkthrough

Walkthrough

This PR introduces a complete build benchmarking system for rsbuild-plugin-react-router. A synthetic fixture generator (scripts/benchmark/fixture.mjs) creates configurable React Router/Rsbuild project trees with multiple route module patterns. A CLI runner (scripts/bench-builds.mjs) executes Rsbuild builds across smoke/default/full profiles, captures wall time, CPU, RSS, and plugin-operation metrics. Two reporting scripts compare two result sets or produce CI-ready report.json/comment.md files. A GitHub Actions workflow orchestrates base-vs-head runs on every PR to main, posts results as PR comments, and persists per-PR benchmark history to a dedicated branch. Supporting changes add bench:* npm scripts, a devDependency on @rsbuild/plugin-react, a .gitignore entry for .benchmark/, and a benchmarks/README.md.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a CI pull request benchmarks workflow.
Description check ✅ Passed The description comprehensively explains the changes, including workflow additions, benchmark scripts, documentation, and validation steps performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pr-benchmark-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
.github/workflows/benchmark.yml (2)

166-173: 💤 Low value

Consider more explicit error handling for history branch creation.

The current logic uses || to handle the case where the history branch doesn't exist. If the first clone fails for a transient reason (e.g., network error) but the second clone succeeds, it would incorrectly create an orphan branch.

While this edge case is unlikely in practice, you could make the logic more explicit by checking if the branch exists before attempting to create it:

Alternative approach
# Check if branch exists
if git ls-remote --exit-code --heads "https://x-access-token:${GH_TOKEN}`@github.com/`${REPOSITORY}.git" "$BENCHMARK_HISTORY_BRANCH" > /dev/null 2>&1; then
  git clone --depth 1 --branch "$BENCHMARK_HISTORY_BRANCH" \
    "https://x-access-token:${GH_TOKEN}`@github.com/`${REPOSITORY}.git" "$history_dir"
else
  git clone --depth 1 "https://x-access-token:${GH_TOKEN}`@github.com/`${REPOSITORY}.git" "$history_dir"
  cd "$history_dir"
  git checkout --orphan "$BENCHMARK_HISTORY_BRANCH"
  git rm -rf .
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/benchmark.yml around lines 166 - 173, The current error
handling logic using the || operator does not properly distinguish between a
missing branch and other types of clone failures such as network errors, which
could lead to incorrectly creating an orphan branch. Replace the || based
fallback logic with an explicit check using git ls-remote with the --exit-code
and --heads flags to verify if the BENCHMARK_HISTORY_BRANCH exists on the remote
repository before attempting to clone with that branch. Use an if-then-else
structure where if the branch exists, clone with the branch argument, otherwise
clone without the branch and then create the orphan branch locally.

1-6: 💤 Low value

Consider adding a timeout and manual trigger.

The workflow currently has no timeout and can only be triggered by pull requests.

Suggested enhancements

Add a generous timeout to catch runaway jobs:

 jobs:
   benchmark:
     name: Compare build benchmarks
     runs-on: ubuntu-latest
+    timeout-minutes: 60

Add workflow_dispatch to allow manual testing:

 on:
   pull_request:
     branches: [main]
+  workflow_dispatch:

Also applies to: 16-19

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/benchmark.yml around lines 1 - 6, The Benchmark workflow
in the on section currently only triggers on pull_request events with no timeout
protection. Add workflow_dispatch to the on section to enable manual triggering
of the workflow, and add a timeout-minutes configuration to the job level to
prevent runaway jobs from consuming excessive resources. This will allow both
automatic execution on pull requests and manual execution via workflow dispatch
while protecting against long-running job scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/compare-benchmarks.mjs`:
- Around line 19-23: The error message in the throw statement uses the same
placeholder `<baseline.json>` for both the `--before` and `--after` parameters,
which is confusing and suggests they should be the same file. Update the error
message to use different, distinct placeholders for each parameter (for example,
use a different filename placeholder for `--after` such as `<comparison.json>`
or `<current.json>`) to clearly indicate that two separate files are required.

In `@scripts/report-benchmark-ci.mjs`:
- Around line 22-26: The error message displayed in the throw statement when
validating the base and head parameters uses the same placeholder
`<baseline.json>` for both `--base` and `--head` arguments, which is confusing
since they represent different files. Update the error message to use distinct
and descriptive placeholders for each parameter, such as `--base <baseline.json>
--head <current.json>` or similar naming that clearly indicates these are two
separate files with different purposes.

---

Nitpick comments:
In @.github/workflows/benchmark.yml:
- Around line 166-173: The current error handling logic using the || operator
does not properly distinguish between a missing branch and other types of clone
failures such as network errors, which could lead to incorrectly creating an
orphan branch. Replace the || based fallback logic with an explicit check using
git ls-remote with the --exit-code and --heads flags to verify if the
BENCHMARK_HISTORY_BRANCH exists on the remote repository before attempting to
clone with that branch. Use an if-then-else structure where if the branch
exists, clone with the branch argument, otherwise clone without the branch and
then create the orphan branch locally.
- Around line 1-6: The Benchmark workflow in the on section currently only
triggers on pull_request events with no timeout protection. Add
workflow_dispatch to the on section to enable manual triggering of the workflow,
and add a timeout-minutes configuration to the job level to prevent runaway jobs
from consuming excessive resources. This will allow both automatic execution on
pull requests and manual execution via workflow dispatch while protecting
against long-running job scenarios.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 72b501b2-640f-4851-8b5e-27be12ecece3

📥 Commits

Reviewing files that changed from the base of the PR and between 0b2b552 and 0004359.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .github/workflows/benchmark.yml
  • .gitignore
  • benchmarks/README.md
  • package.json
  • scripts/bench-builds.mjs
  • scripts/benchmark/fixture.mjs
  • scripts/compare-benchmarks.mjs
  • scripts/report-benchmark-ci.mjs

Comment thread scripts/compare-benchmarks.mjs
Comment thread scripts/report-benchmark-ci.mjs
@ScriptedAlchemy ScriptedAlchemy merged commit 06ae3db into main Jun 21, 2026
7 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the codex/pr-benchmark-ci branch June 21, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant