Skip to content

Convert to Criterion Benching - #180

Open
michaelciraci wants to merge 17 commits into
ejmahler:masterfrom
michaelciraci:use-criterion
Open

michaelciraci wants to merge 17 commits into
ejmahler:masterfrom
michaelciraci:use-criterion

Conversation

@michaelciraci

Copy link
Copy Markdown
Contributor

Closes #159

Comment thread benches/config.rs Outdated
pub fn fast() -> Criterion {
Criterion::default()
.warm_up_time(Duration::from_millis(100))
.measurement_time(Duration::from_millis(100))

@michaelciraci michaelciraci Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you want quick benchmarks. 100 ms is fairly small to me but I think we could go higher for slightly more accurate benchmarks

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old ones I think were on the order of 1s per benchmark, so we definitely have room to increase these.

Comment thread Cargo.toml Outdated
Comment thread Cargo.lock Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up committing the Cargo.lock file because without it, the MSRV tests keep giving errors that criterion dependencies are too old for 1.77. Alternatively we could probably add a couple lines to the pipeline to force a specific version for 1.77, but I think just using a Cargo.lock file to pick exact versions would be more maintainable than a list of commands for specific versions in the dependency tree.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to pin those problematic crates to working versions in the cargo.toml file - that's what we did before raising the msrv. It lets us lock versions of just the crates that are a problem, while leaving the rest untouched.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see you already did that with getrandom. If there are too many problems with criterion on 1.77, we could also just increase the msrv. What's the earliest rust version that would work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we shouldn't increase the MSRV just for a test dependency. I think the worst-case scenario is we make a separate benchmarking crate in this repo and just cd into that to run benchmarks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with just bumping the MSRV here. A low floor is nice when it's free to maintain, but its value is limited, and once a dev only dependency like criterion starts forcing pins or extra structure to keep it, that value doesn't justify the cost anymore.

3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969,
];
for &len in POWERS_OF_THREE {
c.bench_function(&format!("bench_power3_planned_scalar_f32_{len:07}"), |b| {

@ejmahler ejmahler Sep 16, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way with this system of isolating individual benchmarks, or groups? For example, right now I could run cargo bench bench_power3_planned_scalar_f64 and it would isolate just the power3 f64 benchmarks. No need to run the f32 ones, or the power2 ones etc, if i'm specifically working on a power3 feature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can still apply a filter. For that for example, you could do:

cargo bench --bench bench_check_scalar_2to1024 -- bench_power3_planned_scalar_f64

@michaelciraci
michaelciraci marked this pull request as ready for review September 17, 2026 21:01
@HEnquist

Copy link
Copy Markdown
Contributor

When anyway working on this, should we also update the names? For example benches/bench_check_scalar_2to1024.rs currently does 2 to 200, not 1024. Ideally to names that doesn't include the length :)

@michaelciraci

Copy link
Copy Markdown
Contributor Author

When anyway working on this, should we also update the names? For example benches/bench_check_scalar_2to1024.rs currently does 2 to 200, not 1024. Ideally to names that doesn't include the length :)

Done

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.

Convert to Criterion Benching

3 participants