Skip to content

Add CodSpeed performance benchmarks and CI#63

Merged
amondnet merged 3 commits into
mainfrom
codspeed/wizard-1782868576927
Jul 1, 2026
Merged

Add CodSpeed performance benchmarks and CI#63
amondnet merged 3 commits into
mainfrom
codspeed/wizard-1782868576927

Conversation

@codspeed-hq

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

Copy link
Copy Markdown
Contributor

Overview

This PR sets up continuous performance measurement with CodSpeed for the Rust core crate (code-search-please, lib csp). It adds a Criterion-based benchmark suite covering the hot paths and a GitHub Actions workflow that runs the benchmarks on every push and pull request.

What was added

  • Benchmark harness (crates/csp/benches/core.rs) using criterion backed by codspeed-criterion-compat, so the same file runs under vanilla Criterion locally and under CodSpeed instrumentation in CI. Benchmarks cover:
    • tokens::tokenize — identifier tokenization run over every indexed file.
    • tokens::split_identifier — camelCase / snake_case / PascalCase splitting.
    • ranking::penalties::file_path_penalty — per-path penalty matching.
    • ranking::penalties::rerank_top_k — top-k reranking over 500 candidates, with and without path penalties.
  • Dependencies: added codspeed-criterion-compat (aliased as criterion) as a dev-dependency and a [[bench]] target in crates/csp/Cargo.toml. Cargo.lock is updated accordingly.
  • CI workflow (.github/workflows/codspeed.yml): runs on push to main, pull_request, and workflow_dispatch, using OIDC authentication and simulation mode. Actions are pinned by commit hash to match the repository's existing convention.
  • README badge: added the CodSpeed badge to README.md and README.ko.md.

Verification

Built and ran the suite locally under simulation mode — all 5 benchmarks were measured and uploaded successfully:

Benchmark Time
file_path_penalty/mixed_paths 23.5 µs
split_identifier/mixed_batch 8.7 µs
tokenize/source_block 38.0 µs
rerank_top_k/500_candidates_top10_penalised 1.21 ms
rerank_top_k/500_candidates_top10_no_penalty 1.13 ms

cargo fmt --check and cargo clippy --benches -D warnings both pass on the new benchmark.

Next steps

  • Merge to establish the performance baseline on main.
  • Future pull requests will automatically get performance reports comparing against that baseline.
  • Consider extending coverage to the indexing/search pipeline (indexing::index, search) as those code paths stabilize.

Summary by cubic

Adds CodSpeed benchmarks and CI to track Rust core performance on every push and PR. Includes a Criterion-compatible suite for key hot paths and a GitHub Actions workflow in simulation mode.

  • New Features

    • Benchmark suite in crates/csp/benches/core.rs using codspeed-criterion-compat (aliased as criterion), covering tokenize, split_identifier, file_path_penalty, and rerank_top_k (with/without penalties).
    • CI workflow .github/workflows/codspeed.yml for push to main, pull_request, and workflow_dispatch; builds with cargo codspeed build and runs with cargo codspeed run using OIDC and simulation mode.
    • Added criterion dev-dependency and a [[bench]] target in crates/csp/Cargo.toml; updated Cargo.lock.
  • Bug Fixes

    • Switched CodSpeed badge to the working generic badge.json endpoint with a project-specific link in both READMEs.
    • Corrected the score range comment in the make_scores benchmark helper.

Written for commit 44a69e6. Summary will update on new commits.

@socket-security

socket-security Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​codspeed-criterion-compat@​5.0.18610098100100

View full report

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 13 complexity · 0 duplication

Metric Results
Complexity 13
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@codspeed-hq

codspeed-hq Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Congrats! CodSpeed is installed 🎉

🆕 5 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 1, 2026 01:31
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds CodSpeed continuous performance benchmarking for the csp Rust crate. It introduces a Criterion-compatible benchmark suite covering the hot paths (tokenize, split_identifier, file_path_penalty, rerank_top_k) and a new GitHub Actions workflow that builds and runs those benchmarks on every push and pull request using OIDC authentication.

  • Benchmark harness (crates/csp/benches/core.rs): uses codspeed-criterion-compat aliased as criterion, so the same file works locally under Criterion and in CI under CodSpeed's instrumentation. Benchmark data is deterministic and representative of real usage patterns.
  • CI workflow (.github/workflows/codspeed.yml): pins all action hashes (consistent with the repo's existing convention), uses simulation mode (the correct choice for GitHub-hosted runners that lack hardware perf counter support), and sets up proper OIDC-based auth with CodSpeed.
  • Dependencies and lock file: codspeed-criterion-compat added as a dev-only dependency; the transitive dependency tree in Cargo.lock is updated accordingly.

Confidence Score: 5/5

Safe to merge — all changes are purely additive (new dev-only dependency, new bench file, new CI workflow) with zero effect on production code paths.

No production code is modified. The benchmark harness is correctly structured using black_box, the CI workflow follows the repository's existing action-pinning convention, and simulation mode is the appropriate choice for GitHub-hosted runners. The Cargo changes are scoped to dev-dependencies and do not affect published build artifacts.

No files require special attention.

Important Files Changed

Filename Overview
crates/csp/benches/core.rs New benchmark file covering tokenize, split_identifier, file_path_penalty, and rerank_top_k; uses black_box correctly, deterministic fixture data, and proper Criterion group lifecycle (group.finish()).
.github/workflows/codspeed.yml New CI workflow pinning all action hashes to commit SHAs (consistent with existing workflows), using simulation mode appropriate for GitHub-hosted runners, and correctly scoping id-token permissions to OIDC auth with CodSpeed.
crates/csp/Cargo.toml Adds codspeed-criterion-compat as a dev-only dependency aliased as criterion, and declares the bench target with harness=false; no impact on production build.
README.md Adds CodSpeed badge; badge image URL (app.codspeed.io/badge.json) was flagged and addressed in prior review threads.
README.ko.md Mirror of README.md badge change for the Korean README; same badge URL situation addressed in prior review threads.
Cargo.lock Lockfile updated to reflect new transitive dependencies from codspeed-criterion-compat — all dev-only; no production impact.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant GH as GitHub Actions
    participant SR as moonrepo/setup-rust
    participant CC as cargo codspeed build
    participant CA as CodSpeedHQ/action
    participant CR as cargo codspeed run
    participant CS as CodSpeed (OIDC)

    GH->>SR: Install Rust toolchain + cargo-codspeed binary
    SR-->>GH: Toolchain + cache ready
    GH->>CC: cargo codspeed build --workspace
    CC-->>GH: Benchmark binaries in target/codspeed/
    GH->>CA: "Trigger with mode=simulation"
    CA->>CR: cargo codspeed run
    CR-->>CA: Benchmark results (wallclock, simulation)
    CA->>CS: Upload results via OIDC token
    CS-->>CA: Acknowledgement / performance report
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant GH as GitHub Actions
    participant SR as moonrepo/setup-rust
    participant CC as cargo codspeed build
    participant CA as CodSpeedHQ/action
    participant CR as cargo codspeed run
    participant CS as CodSpeed (OIDC)

    GH->>SR: Install Rust toolchain + cargo-codspeed binary
    SR-->>GH: Toolchain + cache ready
    GH->>CC: cargo codspeed build --workspace
    CC-->>GH: Benchmark binaries in target/codspeed/
    GH->>CA: "Trigger with mode=simulation"
    CA->>CR: cargo codspeed run
    CR-->>CA: Benchmark results (wallclock, simulation)
    CA->>CS: Upload results via OIDC token
    CS-->>CA: Acknowledgement / performance report
Loading

Reviews (3): Last reviewed commit: "fix(docs): use working CodSpeed badge en..." | Re-trigger Greptile

Comment thread README.md Outdated
Comment thread README.ko.md Outdated
Comment thread crates/csp/benches/core.rs Outdated
@amondnet amondnet self-assigned this Jul 1, 2026
- Fix CodSpeed badge to project-specific endpoint URL in both READMEs
- Correct make_scores range comment in benchmark (0.001, ~1.0]
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

The project-specific badge.json path returns 404; CodSpeed's badge uses the generic app.codspeed.io/badge.json endpoint with a project-specific link.
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@amondnet
amondnet merged commit 57fb53c into main Jul 1, 2026
13 checks passed
@amondnet
amondnet deleted the codspeed/wizard-1782868576927 branch July 1, 2026 03:48
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.

3 participants