Skip to content

ci: add CodSpeed performance benchmarks - #485

Open
codspeed[bot] wants to merge 2 commits into
mainfrom
codspeed/setup-benchmarks
Open

codspeed[bot] wants to merge 2 commits into
mainfrom
codspeed/setup-benchmarks

Conversation

@codspeed

@codspeed codspeed Bot commented Nov 5, 2026

Copy link
Copy Markdown

Summary

This PR wires the existing Criterion benchmarks into CodSpeed so performance is tracked on every push to main and on every pull request.

Changes

  • Cargo.toml / Cargo.lock: the criterion dev-dependency now points to codspeed-criterion-compat (renamed to criterion). The benchmark source code does not need to change. cargo bench still behaves as before (the compat crate falls back to regular Criterion measurements), so the existing Benchmarks job in ci.yml and its --save-baseline artifact keep working.
  • benches/response_mapping.rs (new): covers transport-facing hot paths that the existing suites did not measure:
    • AppError construction, plain and with metadata (fields, code, retry-after, WWW-Authenticate)
    • AppCode::from_str for built-in and custom codes
    • ErrorResponse::from for both &AppError and an owned AppError
    • JSON serialization of ErrorResponse and ProblemJson
    • Display rendering of AppError
  • .github/workflows/codspeed.yml (new): builds the benchmarks with cargo-codspeed and runs them through CodSpeedHQ/action@v5 in simulation mode on ubuntu-latest. It authenticates with OIDC (id-token: write), so no token secret is needed. It uses the same toolchain and cache actions as ci.yml.
  • README: added the CodSpeed badge to README.template.md and README.md.

Together with the existing comparison and error_paths suites, CodSpeed tracks 28 benchmarks. A local simulation run completed without errors.

Why simulation mode

CPU simulation measures instruction counts and cache behaviour instead of wall-clock time. Results are deterministic, so standard GitHub runners work fine and the noise is low enough to catch small regressions in these microsecond-scale error paths.

Next steps

  1. Merge this PR so main gets its first baseline. After that, every PR gets a performance report comment.
  2. Optionally trigger the CodSpeed workflow manually (workflow_dispatch) to backfill history.
  3. Add new benchmarks to any of the benches/*.rs files. They are picked up automatically, but each new bench file needs a [[bench]] entry with harness = false.

Comment @codspeedbot <request> (for example, "add benchmarks for the axum IntoResponse path") and I'll do it.

codspeed Bot and others added 2 commits November 5, 2026 06:11
Switch the Criterion dev-dependency to codspeed-criterion-compat, add
response mapping benchmarks, a CodSpeed workflow and the README badge.
@codspeed

codspeed Bot commented Nov 5, 2026

Copy link
Copy Markdown
Author

Congrats! CodSpeed is installed 🎉

🆕 28 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


ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Open in CodSpeed

@RAprogramm
RAprogramm marked this pull request as ready for review November 5, 2026 06:13
@codspeed
codspeed Bot requested a review from RAprogramm November 5, 2026 06:19

This branch has not been deployed

No deployments
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.

0 participants