Add benchmark aliases for multiple exact-match identifiers#742
Open
Louisvranderick wants to merge 1 commit intobencherdev:develfrom
Open
Add benchmark aliases for multiple exact-match identifiers#742Louisvranderick wants to merge 1 commit intobencherdev:develfrom
Louisvranderick wants to merge 1 commit intobencherdev:develfrom
Conversation
Add a `benchmark_alias` table so benchmarks can be resolved by alternative names in addition to their primary name, slug, or UUID. This lets users rename benchmarks over time without losing continuity. - New `benchmark_alias` migration with UNIQUE(project_id, alias) and cascading deletes - Split `benchmark.rs` into `benchmark/mod.rs` + `benchmark/alias.rs` - Single-query name resolution via OR + EXISTS in `from_name_id` - TOCTOU-safe alias validation inside write transactions - Batched alias loading to avoid N+1 in list and report endpoints - CLI `--alias` flag on `benchmark create` and `benchmark update` - Generated OpenAPI spec and TypeScript types updated Closes bencherdev#674 Made-with: Cursor
|
| Branch | benchmark-alias |
| Testbed | ubuntu-22.04 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| Adapter::Json | 📈 view plot 🚷 view threshold | 3.94 µs(+7.53%)Baseline: 3.66 µs | 4.49 µs (87.78%) |
| Adapter::Magic (JSON) | 📈 view plot 🚷 view threshold | 4.13 µs(+14.13%)Baseline: 3.62 µs | 4.52 µs (91.49%) |
| Adapter::Magic (Rust) | 📈 view plot 🚷 view threshold | 21.01 µs(-16.43%)Baseline: 25.14 µs | 32.86 µs (63.95%) |
| Adapter::Rust | 📈 view plot 🚷 view threshold | 3.01 µs(+7.48%)Baseline: 2.80 µs | 3.22 µs (93.57%) |
| Adapter::RustBench | 📈 view plot 🚷 view threshold | 2.98 µs(+6.67%)Baseline: 2.80 µs | 3.22 µs (92.81%) |
| head_version_insert/batch/10 | 📈 view plot 🚷 view threshold | 110.88 µs(+9.91%)Baseline: 100.88 µs | 117.82 µs (94.11%) |
| head_version_insert/batch/100 | 📈 view plot 🚷 view threshold | 252.03 µs(+5.56%)Baseline: 238.74 µs | 263.96 µs (95.48%) |
| head_version_insert/batch/255 | 📈 view plot 🚷 view threshold | 475.51 µs(+2.56%)Baseline: 463.65 µs | 498.88 µs (95.31%) |
| head_version_insert/batch/50 | 📈 view plot 🚷 view threshold | 170.22 µs(+5.15%)Baseline: 161.89 µs | 182.14 µs (93.45%) |
| threshold_query/join/10 | 📈 view plot 🚷 view threshold | 157.70 µs(+8.02%)Baseline: 145.99 µs | 168.85 µs (93.40%) |
| threshold_query/join/20 | 📈 view plot 🚷 view threshold | 170.44 µs(+6.08%)Baseline: 160.67 µs | 187.60 µs (90.85%) |
| threshold_query/join/5 | 📈 view plot 🚷 view threshold | 148.00 µs(+7.01%)Baseline: 138.31 µs | 160.91 µs (91.97%) |
| threshold_query/join/50 | 📈 view plot 🚷 view threshold | 213.72 µs(+5.86%)Baseline: 201.89 µs | 231.43 µs (92.35%) |
epompeii
requested changes
Mar 28, 2026
Member
epompeii
left a comment
There was a problem hiding this comment.
Thank you @Louisvranderick! Just took a cursory look.
Comment on lines
+70
to
+71
| #[clap(long = "alias")] | ||
| pub aliases: Vec<BenchmarkName>, |
Member
There was a problem hiding this comment.
The convention is to use the singular form for the field name (ie alias) even when it can be supplied multiple times.
Also using Option<Vec<BenchmarkName>> would be preferred to properly convey the semantics.
Comment on lines
50
to
+56
| pub slug: BenchmarkSlug, | ||
| pub created: DateTime, | ||
| pub modified: DateTime, | ||
| pub archived: Option<DateTime>, | ||
| /// Additional exact-match strings (the primary [`Self::name`] is always a matcher). | ||
| #[serde(default)] | ||
| pub aliases: Vec<BenchmarkName>, |
Member
There was a problem hiding this comment.
Conceptually, aliases should come after slug and before the timestamp fields.
Comment on lines
+77
to
+81
| NameId::Uuid(_) | NameId::Slug(_) => schema::benchmark::table | ||
| .filter(schema::benchmark::project_id.eq(project_id)) | ||
| .filter(Self::eq_name_id(name_id)) | ||
| .first::<Self>(conn) | ||
| .map_err(resource_not_found_err!(Benchmark, (project_id, name_id))), |
Member
There was a problem hiding this comment.
If we're already matching here, it is a bit silly to then have to requery by NameId.
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.
Summary
benchmark_aliastable withUNIQUE(project_id, alias)and cascading foreign keys so benchmarks can keep multiple exact-match aliases over time.NameId::Nameby primary name or alias (single query withOR EXISTS), and validate alias uniqueness inside create/update write transactions to avoid TOCTOU races.--alias, and batch-load aliases in list/report paths to avoid N+1 query behavior.Closes #674
Test plan
cargo fmtcargo clippy -p bencher_schema -p api_projects -p bencher_cli --no-deps --all-targets --all-features -- -Dwarningscargo test -p bencher_schema model::project::benchmarkcargo check --no-default-featurescargo gen-typesoutputs committed (services/api/openapi.json,services/console/src/types/bencher.ts)Made with Cursor