Add CodSpeed performance benchmarks#1676
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
More templates
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/openapi
@orpc/opentelemetry
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/tanstack-query
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
ℹ️ 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-plugindev dependency and a standalonevitest.benchmarks.tsconfig that discoverspackages/*/benches/**/*.bench.ts. - Add
packages/client/benches/rpc-serializer.bench.tsbenchmarking serialize/deserialize for both flat and complex payloads. - Add
packages/server/benches/procedure-call.bench.tsbenchmarking bare, validated, and middleware-wrapped procedure calls. - Add
.github/workflows/codspeed.yamlthat runs benchmarks insimulationmode on pushes tomain, pull requests, andworkflow_dispatch.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
| } | ||
| const serializedFlat = jsonSerializer.serialize(flatPayload) | ||
|
|
||
| describe('rPCJsonSerializer', () => { |
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
Same lower-casing issue here — rPCSerializer should be RPCSerializer or RPC serializer.
| <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" /> |
There was a problem hiding this comment.
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.

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-pluginas 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 frompackages/*/benches/**/*.bench.ts. It is kept separate from the main test config so benchmarks do not interfere with the test suite.packages/client/benches/rpc-serializer.bench.ts— exercisesRPCJsonSerializerandRPCSerializer(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 viacreateRouterClient: 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 onpushtomain, onpull_request, and viaworkflow_dispatch(so CodSpeed can backfill baseline data). It uses OpenID Connect authentication (id-token: write), theCodSpeedHQ/action@v4action insimulationmode, and mirrors the existing CI setup (pnpm/action-setup@v6,pnpm i).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
mainand start reporting performance changes on future pull requests.*.bench.tsfiles into abenches/directory in the relevant package.