Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable codspeed for Rust perf tracking #3231

Merged
merged 8 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: codspeed-benchmarks

on:
# Run on pushes to the main branch
push:
branches:
- "latest"
# Run on pull requests
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

jobs:
benchmarks-rust:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup rust toolchain, cache and cargo-codspeed binary
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-codspeed

- name: Build the benchmark target(s)
run: cargo codspeed build -p sourmash

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
run: "cd src/core && cargo codspeed run"
token: ${{ secrets.CODSPEED_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features --tests
args: --all-features

check_cbindgen:
name: "Check if cbindgen runs cleanly for generating the C headers"
Expand Down
58 changes: 56 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
cargo-udeps
cargo-deny
cargo-wasi
cargo-codspeed
#cargo-semver-checks
nixpkgs-fmt
];
Expand Down
1 change: 1 addition & 0 deletions src/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typed-builder = "0.18.0"
vec-collections = "0.4.3"

[dev-dependencies]
codspeed-criterion-compat = "2.6.0"
proptest = { version = "1.5.0", default-features = false, features = ["std"]}
rand = "0.8.2"
tempfile = "3.10.1"
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/compute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[macro_use]
extern crate criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

use std::fs::File;
use std::io::{Cursor, Read};
Expand All @@ -8,8 +7,6 @@ use needletail::parse_fastx_reader;
use sourmash::cmd::ComputeParameters;
use sourmash::signature::Signature;

use criterion::Criterion;

fn add_sequence(c: &mut Criterion) {
let cp = ComputeParameters::default();
let template_sig = Signature::from_params(&cp);
Expand Down
2 changes: 1 addition & 1 deletion src/core/benches/gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sourmash::signature::Signature;
use sourmash::sketch::Sketch;
use sourmash::{index::calculate_gather_stats, storage::SigStore};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn gather_stats_benchmarks(c: &mut Criterion) {
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/minhash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[macro_use]
extern crate criterion;

use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
Expand All @@ -9,7 +6,7 @@ use sourmash::signature::{Signature, SigsTrait};
use sourmash::sketch::minhash::{KmerMinHash, KmerMinHashBTree};
use sourmash::sketch::Sketch;

use criterion::Criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn intersection(c: &mut Criterion) {
let mut filename = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
Expand Down
5 changes: 1 addition & 4 deletions src/core/benches/nodegraph.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[macro_use]
extern crate criterion;

use std::fs::File;
use std::io::{BufWriter, Cursor, Read};

use sourmash::sketch::nodegraph::Nodegraph;

use criterion::Criterion;
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

fn save_load(c: &mut Criterion) {
let mut data: Vec<u8> = vec![];
Expand Down
Loading