Skip to content

Add CodSpeed performance benchmarks#1676

Open
codspeed-hq[bot] wants to merge 1 commit into
mainfrom
codspeed/wizard-1784123682563
Open

Add CodSpeed performance benchmarks#1676
codspeed-hq[bot] wants to merge 1 commit into
mainfrom
codspeed/wizard-1784123682563

Conversation

@codspeed-hq

@codspeed-hq codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Overview

This PR sets up continuous performance measurement with CodSpeed for the oRPC monorepo. It adds benchmarks for the library's CPU-bound hot paths and a GitHub Actions workflow to track performance on every push and pull request.

What was added

  • @codspeed/vitest-plugin as a dev dependency. The project already uses Vitest, which has a native benchmarking mode (vitest bench), so this integrates cleanly with the existing tooling.
  • vitest.benchmarks.ts — a dedicated Vitest config that enables the CodSpeed plugin and collects benchmarks from packages/*/benches/**/*.bench.ts. It is kept separate from the main test config so benchmarks do not interfere with the test suite.
  • Benchmarks covering representative hot paths:
    • packages/client/benches/rpc-serializer.bench.ts — exercises RPCJsonSerializer and RPCSerializer (serialize/deserialize) with both a small flat payload and a complex nested payload mixing the special types the serializer handles (Date, BigInt, Set, Map, URL, RegExp). Serialization runs on every RPC request/response, making it a critical path.
    • packages/server/benches/procedure-call.bench.ts — exercises the server-side procedure call path via createRouterClient: a bare handler, a handler with Zod input/output validation, and one with validation plus two middlewares. This is the code executed for every incoming request.
  • .github/workflows/codspeed.yaml — runs the benchmarks on push to main, on pull_request, and via workflow_dispatch (so CodSpeed can backfill baseline data). It uses OpenID Connect authentication (id-token: write), the CodSpeedHQ/action@v4 action in simulation mode, and mirrors the existing CI setup (pnpm/action-setup@v6, pnpm i).
  • CodSpeed badge in the README.

Verification

Benchmarks were run locally in simulation mode with the CodSpeed CLI and all 8 benchmarks executed successfully with results uploaded to the CodSpeed dashboard.

Next steps

  • Once merged, CodSpeed will establish a baseline from main and start reporting performance changes on future pull requests.
  • Additional benchmarks can be added for other packages (e.g. contract validation, OpenAPI generation) by dropping *.bench.ts files into a benches/ directory in the relevant package.

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orpc Ready Ready Preview, Comment Jul 15, 2026 2:04pm

@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown
Author

Congrats! CodSpeed is installed 🎉

🆕 8 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

@codspeed-hq codspeed-hq Bot marked this pull request as ready for review July 15, 2026 14:04
@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown
More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1676

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@1676

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1676

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@1676

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1676

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@1676

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@1676

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1676

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1676

@orpc/next

npm i https://pkg.pr.new/@orpc/next@1676

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1676

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@1676

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@1676

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@1676

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@1676

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1676

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1676

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1676

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1676

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1676

commit: 12b281c

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog Bot 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.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes — adds CodSpeed continuous performance benchmarks for RPCJsonSerializer, RPCSerializer, and server-side createRouterClient hot paths, plus a CI workflow and README badge.

  • Add @codspeed/vitest-plugin dev dependency and a standalone vitest.benchmarks.ts config that discovers packages/*/benches/**/*.bench.ts.
  • Add packages/client/benches/rpc-serializer.bench.ts benchmarking serialize/deserialize for both flat and complex payloads.
  • Add packages/server/benches/procedure-call.bench.ts benchmarking bare, validated, and middleware-wrapped procedure calls.
  • Add .github/workflows/codspeed.yaml that runs benchmarks in simulation mode on pushes to main, pull requests, and workflow_dispatch.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

}
const serializedFlat = jsonSerializer.serialize(flatPayload)

describe('rPCJsonSerializer', () => {

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.

The describe label is lower-cased to rPCJsonSerializer, which reads awkwardly. Use RPCJsonSerializer or a plain phrase like RPC JSON serializer to match the class name.

})
})

describe('rPCSerializer', () => {

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.

Same lower-casing issue here — rPCSerializer should be RPCSerializer or RPC serializer.

Comment thread README.md
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fclient?logo=npm" />
</a>
<a href="https://app.codspeed.io/middleapi/orpc?utm_source=badge">
<img alt="CodSpeed" src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" />

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.

This badge uses the generic https://codspeed.io/badge.json endpoint, so it won't show project-specific status. If CodSpeed exposes a per-repo endpoint for middleapi/orpc, switch to that so the badge reflects this repository.

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