#2
Add CodSpeed continuous performance measurement
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: thecriteriondev-dependency now points atcodspeed-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_provideslookups, and fullSolver::solveruns on small, medium and large dependency graphs.crates/riff-core/benches/manifest.rs(new): measuresparse_manifest,compute_content_hashandvalidate_composer_manifestagainst the Composer manifest fixture already in the repo, plus lock file parse/serialize round trips (25 and 200 packages) andload_package_configover 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 onpull_request, pushes tomainandworkflow_dispatch. It installscargo-codspeed, builds the benchmark targets withcargo codspeed build --workspace --locked --measurement-mode simulationand runs them throughCodSpeedHQ/actioninsimulationmode. Actions are pinned by commit SHA and the Swatinem cache configuration follows the existingci.ymlconventions; the workflow passesactionlint(the same version pinned inmise.toml).- Authentication uses OpenID Connect, so no token secret is needed — the job requests
id-token: writeandcontents: readonly. README.md: added the CodSpeed badge next to the CI badge.
Verification
cargo codspeed build --workspace --locked --measurement-mode simulationandcodspeed run --mode simulation -- cargo codspeed runwere executed locally: all 23 benchmarks across the four suites were measured and uploaded successfully.cargo fmt --allandcargo clippy --benches --all-features --locked -- -D warningspass for the touched crates.actionlintpasses on the new workflow.
Notes
- Simulation (CPU) mode is used, which is deterministic and hardware-agnostic, so the benchmarks can run on standard
ubuntu-latestrunners 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
mainbecomes the baseline; after that, every pull request gets a performance report comparing againstmain. - If you want coverage of another hot path (for example autoload class map generation or archive extraction), a new
benches/*.rsfile in the relevant crate plus a[[bench]]entry is all that is needed — the workflow already builds every benchmark in the workspace.
Activity
1This pull request is a draft
Merging is unavailable until it is marked ready for review.
Congrats! CodSpeed is installed 🎉
🆕 23new benchmarks were detected.You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
Detected benchmarks
parse[200]: 6.1 msparse[25]: 1 msserialize[200]: 2.8 msserialize[25]: 493.8 µscontent_hash: 271.5 µsparse: 264.3 µsvalidate: 3.1 msload_package_config[200]: 5.2 mspool_build[288]: 2 mssolve[large]: 20.6 mssolve[medium]: 6.8 mssolve[small]: 1.1 mspool_what_provides: 66.6 µsnormalize_versions: 23.9 µsparse_constraints: 140.9 µsphp_version_compare: 8.9 µssemver_satisfies_parsed: 22.9 µssemver_satisfies: 115.6 µssemver_sort: 43.8 µsspdx_identifier_by_name: 36.1 µs