chore: establish performance baselines#41
Conversation
Merging this PR will create unknown performance changes
Performance Changes
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Establishes a pinned, comparable performance baseline for SugarPath by introducing a deterministic allocation-snapshot harness, reshaping Criterion benches around a Rolldown-like corpus with stable IDs, committing cross-platform allocation snapshots, and wiring CI to validate those baselines.
Changes:
- Add
tasks/track_allocationsexecutable that measures and snapshot-checks global allocator call counts/bytes for a fixed set of SugarPath scenarios. - Rework Criterion benches to use Rolldown-shaped workloads and stable benchmark identifiers; add a dedicated
rolldownbench. - Pin toolchain/deps and CI behavior (Rust 1.97.0, committed
Cargo.lock, tuned bench profile, allocation snapshot checks, CodSpeed simulation+memory).
Reviewed changes
Copilot reviewed 27 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/track_allocations/src/main.rs | New allocation tracking executable with deterministic scenarios and snapshot rendering/checking. |
| tasks/track_allocations/README.md | Documents how to generate/check allocation snapshots and interpret results. |
| tasks/track_allocations/Cargo.toml | Defines the non-published workspace task crate and rolldown feature flag. |
| tasks/track_allocations/.gitignore | Ignores the task’s local target/ output. |
| rust-toolchain.toml | Pins the Rust toolchain and required components. |
| Cargo.toml | Converts repo to a workspace, pins bench profile settings, adds deps/benches, and sets publish exclusions. |
| Cargo.lock | Commits a locked dependency graph for reproducible benchmark baselines. |
| .cargo/config.toml | Adds cargo allocs / cargo allocs-rolldown aliases for snapshot workflows. |
| benchmarks/README.md | Explains the baseline philosophy (Criterion vs CodSpeed vs allocations) and usage. |
| benchmarks/windows-gnu.md | Optional/gated Docker+Wine instructions for Windows-GNU reproduction. |
| benchmarks/rolldown-path-distribution.sh | Script to summarize Rolldown path distribution for workload justification. |
| benchmarks/allocations/x86_64-unknown-linux-gnu-default.snap | Committed Linux default allocation snapshot baseline. |
| benchmarks/allocations/x86_64-unknown-linux-gnu-rolldown.snap | Committed Linux cached_current_dir allocation snapshot baseline. |
| benchmarks/allocations/x86_64-pc-windows-msvc-default.snap | Committed Windows MSVC default allocation snapshot baseline. |
| benchmarks/allocations/x86_64-pc-windows-msvc-rolldown.snap | Committed Windows MSVC cached_current_dir allocation snapshot baseline. |
| benchmarks/allocations/aarch64-apple-darwin-default.snap | Committed macOS ARM64 default allocation snapshot baseline. |
| benchmarks/allocations/aarch64-apple-darwin-rolldown.snap | Committed macOS ARM64 cached_current_dir allocation snapshot baseline. |
| benches/support/mod.rs | Sets mimalloc as the global allocator for benchmark binaries; exports workloads. |
| benches/support/workloads.rs | New Rolldown-shaped path corpora and relative/to_slash/normalize fixtures (incl. invalid Unicode). |
| benches/absolutize.rs | Reshaped absolutize benchmarks around Rolldown-like paths and explicit cwd strategies. |
| benches/normalize.rs | Replaces ad-hoc fixtures with corpus-based normalize benchmarks and stable IDs. |
| benches/relative.rs | Replaces ad-hoc relative benchmarks with Rolldown-shaped cases and stable IDs. |
| benches/to_slash.rs | Replaces ad-hoc to_slash benchmarks with corpus-based cases, owned-input rows, and Windows branches. |
| benches/as_path.rs | Benchmarks as_path on Rolldown corpus vs Path::new. |
| benches/rolldown.rs | New composed pipeline benchmarks modeling Rolldown call-site shapes and outputs. |
| benches/fixtures.rs | Removes old ad-hoc fixture lists superseded by workload corpus. |
| .gitignore | Stops ignoring Cargo.lock so baselines remain reproducible. |
| .github/workflows/test.yaml | Adds allocation snapshot validation job and tightens test/lint invocations under --locked --workspace. |
| .github/workflows/codspeed.yml | Runs CodSpeed in simulation+memory modes with pinned toolchain and build flags. |
Comments suppressed due to low confidence (1)
Cargo.toml:20
criterionis imported throughout the benches, but the dev-dependency is declared ascriterion2, which meansuse criterion::...will fail to compile. Rename the dependency key tocriterion(usingpackage = "criterion2") and update thecodspeedfeature to reference the renamed dependency.
[features]
# Enable `cached_current_dir` will make `SugarPath` to only call `std::env::current_dir` once for all path operations.
cached_current_dir = []
codspeed = ["criterion2/codspeed"]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| edition = "2024" | ||
| license = "MIT" | ||
| autobenches = false | ||
| exclude = [".agents/", ".cargo/", ".github/", "AGENTS.md", "CLAUDE.md", "benchmarks/"] |
| bencher.iter_with_setup_wrapper(|runner| { | ||
| let base = PathBuf::from(black_box(ROLLDOWN_ROOT)); | ||
| runner.run(|| { | ||
| let input = Path::new(black_box(RELATIVE_MODULE)); | ||
| let output = input.absolutize_with(Cow::Owned(base)); | ||
| drop(black_box(output)); | ||
| }); | ||
| }); |
Summary
cached_current_dirWhy
PR #40 currently introduces most of this measurement infrastructure together with the API and implementation rewrite, so CodSpeed has no accepted pre-optimization run for the important rows and reports them as new benchmarks. This PR runs the existing v2 implementation against the same inputs and requested outputs first.
Where v2 has no consuming API, the borrowed- and owned-receiver baseline rows deliberately execute the same operation. After this lands, #40 can keep these IDs and replace only the owned-receiver body, making time and allocation changes directly visible.
Merge this PR first and let CodSpeed record it on
main; then rebase/update #40 to preserve these benchmark and allocation scenario identities. Rows whose breaking API intentionally changes the returned spelling or root semantics remain contract coverage and are documented as unsuitable for same-output speed claims.Scope and impact
src/**, test, public API, version, or changelog changesValidation
cargo fmt --all -- --checkcargo test --locked --workspacecargo test --locked --workspace --all-featurescargo clippy --locked --workspace --all-targets --all-features -- -D warningsRUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --all-features --no-depscargo bench --locked --workspace --no-runcargo bench --locked --workspace --all-features --no-runcargo package --locked --allow-dirty