Repository navigation
fix: normalize the file part of divan and codspeed_uri! URIs - #212
Conversation
[Medium impact] This PR appears safe to merge. SummaryNormalizes
Intentional changes acknowledged by Reviews (1) · Last reviewed commit: "fix: normalize the file part of divan an..." · Reviewed by Greptile |
Merging this PR will degrade performance by 25.99%4 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
6c26ec5 to
42f1d31
Compare
divan and codspeed_uri! put file!() in the benchmark URI as is. rustc keeps the `.` and `..` segments of a module included with `#[path = "../x.rs"]` or of a target with `[[bench]] path = "../x.rs"`, so the URI got e.g. `benches/../src/x.rs`. A URL parser resolves these segments, which breaks the benchmark page and the flame graph. The file part is now normalized lexically: `benches/../src/x.rs` becomes `src/x.rs`. It stays relative to the Cargo workspace root, so a path above it keeps its leading `..`. Paths without a dot segment are returned unchanged, without allocating. The benchmark name and args keep their dot segments: they are not a path. URIs change only for benchmarks whose file!() has a dot segment. Refs COD-4223 Co-Authored-By: Claude <noreply@anthropic.com>
42f1d31 to
1c98769
Compare
Removes the
.and..segments from the file part of the benchmark URIs built by divan (both the instrumented compat layer and the walltime fork) and bycodspeed_uri!.Both put
file!()in the URI as is. rustc keeps the dot segments of a module included with#[path = "../x.rs"], or of a target declared with[[bench]] path = "../x.rs", so a benchmark got a URI likebenches/../src/inner_bench.rs::inner_bench::inner. A URL parser resolves these segments, so the benchmark page 404s and the flame graph can't be stored or downloaded.The new
codspeed::utils::normalize_file_pathnormalizes the path lexically, without touching the file system:file!()benches/../src/inner_bench.rssrc/inner_bench.rsbenches/../../shared/escape_bench.rs../shared/escape_bench.rsbenches/bench.rsbenches/bench.rs(unchanged, borrowed)... Making divan URIs relative to the git root would change the URIs of every divan user whose workspace isn't at the git root, so it's tracked separately (COD-4451)...in the benchmark name or args is legitimate and stays.Verified on a divan crate with a
#[path]module inside the workspace, one above it, and args containing.., built against this branch with[patch.crates-io]: the URIs are the ones in the table above, and the args are unchanged.URI change: only benchmarks whose
file!()has a dot segment get a new URI, so their history restarts.Refs COD-4223: the issue also covers fixes in other integrations and in the CodSpeed app, so it stays open.