#2

Add CodSpeed continuous performance measurement

Draftcodspeed-hq[bot]wants to merge intofrom

This sets up continuous performance measurement with CodSpeed for the Riff workspace: the existing semver benchmarks now report to CodSpeed, and new benchmarks cover the dependency solver, manifest/lock handling and SPDX license validation.

Changes

Benchmark harness

  • crates/riff-semver: the criterion dev-dependency now points at codspeed-criterion-compat (criterion = { version = "5", package = "codspeed-criterion-compat" }). The benchmark code is unchanged — the compatibility layer keeps the criterion API and falls back to regular criterion behaviour when run outside CodSpeed.
  • crates/riff-core/benches/solver.rs (new): builds synthetic, layered package universes (offline and deterministic) and measures pool construction, Pool::what_provides lookups, and full Solver::solve runs on small, medium and large dependency graphs.
  • crates/riff-core/benches/manifest.rs (new): measures parse_manifest, compute_content_hash and validate_composer_manifest against the Composer manifest fixture already in the repo, plus lock file parse/serialize round trips (25 and 200 packages) and load_package_config over 200 repository metadata entries.
  • crates/riff-spdx/benches/spdx.rs (new): measures license database loading, expression validation, identifier lookups and reverse name lookups.

CI

  • .github/workflows/codspeed.yml (new): runs on pull_request, pushes to main and workflow_dispatch. It installs cargo-codspeed, builds the benchmark targets with cargo codspeed build --workspace --locked --measurement-mode simulation and runs them through CodSpeedHQ/action in simulation mode. Actions are pinned by commit SHA and the Swatinem cache configuration follows the existing ci.yml conventions; the workflow passes actionlint (the same version pinned in mise.toml).
  • Authentication uses OpenID Connect, so no token secret is needed — the job requests id-token: write and contents: read only.
  • README.md: added the CodSpeed badge next to the CI badge.

Verification

  • cargo codspeed build --workspace --locked --measurement-mode simulation and codspeed run --mode simulation -- cargo codspeed run were executed locally: all 23 benchmarks across the four suites were measured and uploaded successfully.
  • cargo fmt --all and cargo clippy --benches --all-features --locked -- -D warnings pass for the touched crates.
  • actionlint passes on the new workflow.

Notes

  • Simulation (CPU) mode is used, which is deterministic and hardware-agnostic, so the benchmarks can run on standard ubuntu-latest runners with low variance.
  • The dependency solver benchmarks use synthetic package graphs rather than network metadata, so they never hit Packagist and stay stable across runs.

Next steps

  • Merge the PR so the first run on main becomes the baseline; after that, every pull request gets a performance report comparing against main.
  • If you want coverage of another hot path (for example autoload class map generation or archive extraction), a new benches/*.rs file in the relevant crate plus a [[bench]] entry is all that is needed — the workflow already builds every benchmark in the workspace.

Activity

1
codspeed-hq[bot]2mo ago

Congrats! CodSpeed is installed 🎉

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


:information_source: Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


This pull request is a draft

Merging is unavailable until it is marked ready for review.