bench(spann): add a Criterion harness for the distance kernels - #782
Open
ohdearquant wants to merge 1 commit into
Open
bench(spann): add a Criterion harness for the distance kernels#782ohdearquant wants to merge 1 commit into
ohdearquant wants to merge 1 commit into
Conversation
Add a Criterion harness for the l2_squared and cosine_distance kernels in ruvector-spann, covering dimensions 128/384/768/1536 with seeded random inputs instead of constant fills.
ohdearquant
marked this pull request as ready for review
August 3, 2026 18:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Criterion benchmark harness for
ruvector-spann's distance module. Thecrate has distance kernels in
src/distance.rs:l2_squaredis on the indexhot path (
src/kmeans.rs,src/index.rs), andcosine_distanceis a publickernel with no production call site today, covered by the same harness. Until
now the crate had no
benches/directory, no
[[bench]]target, and nocriteriondev-dependency — so aperformance change to this crate cannot be measured inside the crate itself.
No behaviour change. The only
Cargo.tomladditions are under[dev-dependencies](criterion,rand, both at the workspace-pinnedversions) plus the
[[bench]]declaration.Design notes
dimensions 128 / 384 / 768 / 1536.
StdRng(gen_range(-1.0..1.0)), not constantfills, so runs are reproducible while still exercising data-dependent
behaviour. Several existing benches elsewhere in the workspace use
constant-fill vectors, which say nothing about data dependence; this harness
deliberately does not inherit that.
black_boxon both inputs and outputs.Verification
cargo bench -p ruvector-spann --bench distance -- --test: all 8 casesprint
Success.cargo fmt --all -- --check: clean.cargo clippy -p ruvector-spann --all-targets: no Clippy diagnostic namesthe new bench file. Pre-existing, unrelated output remains: Cargo's
workspace profile-ignored warnings and the
ruvector-attentionbench/bindouble-target warning, both untouched here.
Why now
#763 proposes an optional distance backend for this crate and currently has no
way to carry before/after numbers. This harness is the missing instrument, kept
as its own PR so the instrument and the change it would measure are reviewed
separately.
Note on this PR's CI.
Tests (core-and-rest)is red on every branch in this repository,including
main: the job is cancelled at its 240-minute cap while still compiling and neverreaches the test phase. #786 restores the exclusion list that the shard's
packages:value losesto a shell comment, #784 unblocks the
ruvector-filtertest target that the compiler cannotfinish, and #787 fixes a deadlock waiting behind both. That failure is not caused by this branch.