Skip to content

bench: measure Rust basedir path stripping - #2838

Open
tcashel wants to merge 6 commits into
mozilla:mainfrom
tcashel:codex/rust-basedirs-benchmark
Open

bench: measure Rust basedir path stripping#2838
tcashel wants to merge 6 commits into
mozilla:mainfrom
tcashel:codex/rust-basedirs-benchmark

Conversation

@tcashel

@tcashel tcashel commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Adds a Divan benchmark for the Rust path-basedir matching introduced in #2813. It measures 100 path lookups with 0, 1, 8, and 32 configured roots, using a mix of matching and nonmatching paths.

Dependency

This PR is stacked on #2813. Until #2813 merges, GitHub includes that implementation in this PR diff. The benchmark-only comparison is: tcashel/sccache@codex/rust-basedirs...codex/rust-basedirs-benchmark

Prior measurements

In the local Apple silicon run documented on #2813, 100 lookups took approximately 0.208 microseconds with one configured root and 4.33 microseconds with 32 roots.

I used OpenAI Codex during implementation and review.

@codecov-commenter

codecov-commenter commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.54%. Comparing base (b45240d) to head (5b48e27).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/rust.rs 99.25% 2 Missing ⚠️
src/util.rs 99.37% 1 Missing ⚠️
tests/sccache_cargo.rs 98.52% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2838      +/-   ##
==========================================
- Coverage   73.71%   72.54%   -1.17%     
==========================================
  Files          72       72              
  Lines       37932    39632    +1700     
==========================================
+ Hits        27963    28753     +790     
- Misses       9969    10879     +910     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread docs/Configuration.md
* `SCCACHE_ALLOW_CORE_DUMPS` to enable core dumps by the server
* `SCCACHE_CONF` configuration file path
* `SCCACHE_BASEDIRS` base directory (or directories) to strip from paths for cache key computation. This is similar to ccache's `CCACHE_BASEDIR` and enables cache hits across different absolute paths when compiling the same source code. Multiple directories can be separated by `;` on Windows hosts and by `:` on any other operating system. When multiple directories are specified, the longest matching prefix is used. Path matching is **case-insensitive** on Windows and **case-sensitive** on other operating systems. Environment variable takes precedence over file configuration. Only absolute paths are supported; relative paths will cause an error and prevent the server from start.
* `SCCACHE_BASEDIRS` base directory (or directories) to strip from paths for cache key computation. This is similar to ccache's `CCACHE_BASEDIR` and enables cache hits across different absolute paths when compiling the same source code. Multiple directories can be separated by `;` on Windows hosts and by `:` on any other operating system. When multiple directories are specified, the longest matching prefix is used. Path matching is **case-insensitive** on Windows and **case-sensitive** on other operating systems. For Rust, sccache normalizes matching absolute source arguments, the source side of `--remap-path-prefix`, Cargo path variables, tracked environment dependency values that are absolute paths, and the current working directory. Environment variable takes precedence over file configuration. Only absolute paths are supported; relative paths will cause an error and prevent the server from starting. This setting changes cache keys but does not rewrite paths embedded in artifacts; a Rust artifact can retain an absolute path from the compilation that populated the cache.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sorry but i just would like the benchmark change in this PR

Comment thread docs/Rust.md
* Procedural macros that read files from the filesystem may not be cached properly.
* `rustc`'s incremental compilation needs to be disabled. See [The Cargo Book](https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
* Crates that invoke the system linker cannot be cached. Examples are `bin`, `dylib`, `cdylib`, and `proc-macro` crates.
* `SCCACHE_BASEDIRS` normalizes matching paths in cache-key inputs, but it does not rewrite paths embedded in artifacts. For example, a crate that uses `env!("CARGO_MANIFEST_DIR")` can retain the path from the compilation that populated a shared cache entry.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

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.

3 participants