Skip to content

fix: normalize the file part of divan and codspeed_uri! URIs - #212

Merged
lvaroqui merged 1 commit into
mainfrom
fix/divan-normalize-uri-file
Nov 27, 2026
Merged

lvaroqui merged 1 commit into
mainfrom
fix/divan-normalize-uri-file

Conversation

@lvaroqui

Copy link
Copy Markdown
Contributor

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 by codspeed_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 like benches/../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_path normalizes the path lexically, without touching the file system:

file!() File part of the URI
benches/../src/inner_bench.rs src/inner_bench.rs
benches/../../shared/escape_bench.rs ../shared/escape_bench.rs
benches/bench.rs benches/bench.rs (unchanged, borrowed)
  • The base stays the Cargo workspace root, so a file above it keeps its leading ... 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).
  • Only the file part is normalized: a .. in the benchmark name or args is legitimate and stays.
  • Paths without a dot segment are returned as is, so their URIs don't change on any platform.

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.

@lvaroqui
lvaroqui marked this pull request as ready for review November 26, 2026 15:09
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · This PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Normalizes . and .. in benchmark source-file paths for Divan and codspeed_uri!.

  • Benchmark URIs clean dot segments from source-file paths.

Intentional changes acknowledged by lvaroqui: paths keep leading .. when they leave the workspace; moving the base to the git root is deferred to COD-4451 to avoid changing other benchmark identities; benchmarks whose file paths change start new history.

Reviews (1) · Last reviewed commit: "fix: normalize the file part of divan an..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 25.99%

4 warnings, 1 note

⚠️ Unable to measure the execution of 59 benchmarks

These benchmarks measured no execution time, so their results are not comparable and count as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ 17 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 169 benchmarks are too noisy to detect regressions

Their results vary so much between runs that only very large changes would be flagged. Investigate what causes this variance to catch their regressions.

See affected benchmarks

ℹ️ 57 benchmarks have no flamegraph

  • The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze. (9 benchmarks)
  • The flamegraph wasn't generated: no execution data was recorded while the benchmark ran. Make sure the compiler didn't optimize the benchmark out. (48 benchmarks)

See affected benchmarks

⚡ 1 improved benchmark
❌ 4 (👁 1) regressed benchmarks
✅ 613 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime add_two_integers[(42, 13)] 6 ns 19 ns -68.42%
❌ Walltime find_highest_set_bit[255] 5 ns 7 ns -28.57%
❌ Walltime build_vec 219 ns 241 ns -9.13%
⚡ CPU Simulation spawn_on_parent_runtime 60.6 µs 42 µs +44.41%
👁 Walltime event_without_span 3 ns 4 ns -25%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/divan-normalize-uri-file (1c98769) with main (a4cf5ba)

Open in CodSpeed

@not-matthias not-matthias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! :)

Comment thread crates/codspeed/src/utils.rs Resolved
@lvaroqui
lvaroqui force-pushed the fix/divan-normalize-uri-file branch from 6c26ec5 to 42f1d31 Compare November 26, 2026 17:28
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>
@lvaroqui
lvaroqui force-pushed the fix/divan-normalize-uri-file branch from 42f1d31 to 1c98769 Compare November 26, 2026 17:30
@lvaroqui
lvaroqui merged commit 9bd76a6 into main Nov 27, 2026
49 of 50 checks passed
@lvaroqui
lvaroqui deleted the fix/divan-normalize-uri-file branch November 27, 2026 08:48
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.

2 participants