Skip to content

fix(divan)!: make benchmark URIs relative to the git root - #213

Draft
lvaroqui wants to merge 1 commit into
mainfrom
cod-4451-divan-benchmark-uris-are-relative-to-the-cargo
Draft

lvaroqui wants to merge 1 commit into
mainfrom
cod-4451-divan-benchmark-uris-are-relative-to-the-cargo

Conversation

@lvaroqui

Copy link
Copy Markdown
Contributor

divan and codspeed_uri! (used by codspeed_bench!) build the file part of the benchmark URI from file!(), which is relative to the Cargo workspace root. criterion and bencher use a path relative to the git root. When the Cargo workspace sits in a subdirectory of the repository, divan gives benches/x.rs where criterion gives rust/benches/x.rs for the same file.

get_git_relative_path now computes the file part for every integration:

  • It canonicalizes the path, then strips the git root.
  • When canonicalization fails (e.g. the file no longer exists), it removes the . and .. segments without touching the file system, then strips the git root. Before, criterion and bencher kept the path as is in this case, so the URI could hold an absolute path and .. segments.

divan (compat and fork) and codspeed_uri! call it through get_git_relative_file_path(file!()), which joins file!() to CODSPEED_CARGO_WORKSPACE_ROOT, like caller_file_path already does for criterion. normalize_file_path from #212 was never released; it becomes the private normalize_path fallback.

Breaking change

divan and codspeed_bench! benchmarks of a Cargo workspace below the git root get a new URI, so their history restarts. This should ship in a major release, after benchmark rename support (COD-460) lands.

Closes COD-4451

divan and codspeed_uri!, which codspeed_bench! uses, built the file part of the URI
from file!(), which is relative to the Cargo workspace root. criterion and bencher
use a path relative to the git root. When the Cargo workspace sits in a
subdirectory of the repository, divan gave `benches/x.rs` where criterion gave
`rust/benches/x.rs` for the same file.

get_git_relative_path now computes the file part for every integration. It
canonicalizes the path, then strips the git root. When canonicalization fails
(e.g. the file no longer exists), it removes the `.` and `..` segments without
touching the file system, then strips the git root. Before, criterion and bencher
kept the path as is in this case, so the URI could hold an absolute path and `..`
segments.

divan and codspeed_uri! call it through get_git_relative_file_path, which joins
file!() to CODSPEED_CARGO_WORKSPACE_ROOT, like caller_file_path does for criterion.
The unreleased normalize_file_path becomes the private normalize_path fallback.

BREAKING CHANGE: divan and codspeed_bench! benchmarks of a Cargo workspace below
the git root get a new URI, so their history restarts.
Closes COD-4451
Co-Authored-By: Claude <noreply@anthropic.com>
@codspeed

codspeed Bot commented Nov 27, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

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

⚡ 5 improved benchmarks
❌ 1 regressed benchmark
✅ 612 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime spawn_on_parent_runtime 20.4 µs 27 µs -24.27%
⚡ CPU Simulation spawn_on_parent_runtime 70.1 µs 37 µs +89.51%
⚡ Walltime event_without_span 4 ns 3 ns +33.33%
⚡ Walltime permutations[7] 978.9 µs 830.7 µs +17.84%
⚡ Walltime recursive_memoized[HashMap<u64, u64>, 10] 2.1 µs 1.8 µs +15.9%
⚡ Walltime build_vec 239 ns 217 ns +10.14%

Tip

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


Comparing cod-4451-divan-benchmark-uris-are-relative-to-the-cargo (8be5bbc) with main (9bd76a6)

Open in CodSpeed

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.

1 participant