Add benchmark aliases for multiple exact-match identifiers#742
Add benchmark aliases for multiple exact-match identifiers#742Louisvranderick wants to merge 5 commits 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
left a comment
There was a problem hiding this comment.
Thank you @Louisvranderick! Just took a cursory look.
| #[clap(long = "alias")] | ||
| pub aliases: Vec<BenchmarkName>, |
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.
| 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>, |
There was a problem hiding this comment.
Conceptually, aliases should come after slug and before the timestamp fields.
| 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))), |
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.
- CLI: singular alias with Option<Vec<BenchmarkName>>; preserve wire JSON - Reorder JsonBenchmark (aliases after slug); regenerate bencher.ts - Refactor QueryBenchmark::from_name_id; fix plus report/job priority handling - Fix benchmark list total_count error mapping; batch alias loading for GET list Made-with: Cursor
|
Pushed a follow-up commit (e680a56) that covers the review notes. The CLI now uses a single alias flag with an optional list of names, and the JSON we send is the same as before. On the wire type, aliases sits right after slug, and the generated bencher.ts matches. QueryBenchmark::from_name_id is spelled out explicitly (UUID, slug, primary name, then alias lookup) and the old helper macro is gone, with tests updated. For plus / otel builds, priority and is_claimed are only threaded where the feature cfg allows, so bencher_schema compiles with plus again. The benchmark list endpoint batch-loads aliases, and the name/search filters also match alias rows. I also fixed a copy-paste bug where list total_count errors were attributed to Plot instead of Benchmark. Relying on CI for the full run. |
Resolve conflicts in report/mod.rs and runner/job.rs: keep report idempotency from devel; align priority/otel cfg with QueryReport::process_results (plus+otel). Made-with: Cursor
|
| Branch | benchmark-alias |
| Testbed | intel-v1 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| Adapter::Json | 📈 view plot 🚷 view threshold | 4.57 µs(+0.46%)Baseline: 4.54 µs | 4.63 µs (98.53%) |
| Adapter::Magic (JSON) | 📈 view plot 🚷 view threshold | 4.41 µs(-0.15%)Baseline: 4.42 µs | 4.46 µs (98.79%) |
| Adapter::Magic (Rust) | 📈 view plot 🚷 view threshold | 25.12 µs(-0.09%)Baseline: 25.15 µs | 26.52 µs (94.75%) |
| Adapter::Rust | 📈 view plot 🚷 view threshold | 3.36 µs(-0.34%)Baseline: 3.37 µs | 3.45 µs (97.38%) |
| Adapter::RustBench | 📈 view plot 🚷 view threshold | 3.35 µs(-0.56%)Baseline: 3.37 µs | 3.47 µs (96.54%) |
Made-with: Cursor
- Use pointer double-cast for libc::signal and document unsafe for function-casts-as-integer / fn_to_numeric_cast_any. - Drop stale crate-level expect(multiple_inherent_impl); lint no longer fires. Made-with: Cursor
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