Skip to content

perf: micro-optimize resolver normal path#215

Draft
hardfist wants to merge 5 commits into
mainfrom
perf/micro-optimize-resolver
Draft

perf: micro-optimize resolver normal path#215
hardfist wants to merge 5 commits into
mainfrom
perf/micro-optimize-resolver

Conversation

@hardfist
Copy link
Copy Markdown
Contributor

@hardfist hardfist commented May 17, 2026

Goal

Micro-optimize the resolver normal path by at least 5% using exact Callgrind instruction references as the primary metric.

Benchmark

Target benchmark:

RUSTFLAGS="-C debuginfo=1 -C strip=none -g" cargo codspeed build
CODSPEED_CARGO_WORKSPACE_ROOT=$PWD valgrind --tool=callgrind --callgrind-out-file="$out_dir/callgrind.out.%p" "$bench_bin" "benches/resolver.rs::resolver::bench_resolver::resolver[single-thread]" --exact

Metric: Callgrind Ir from CodSpeed Valgrind.

Baseline: 116,917,041 Ir.
5% target threshold: 111,071,189 Ir.
Final: 109,733,110 Ir (-7,183,931, -6.15%).

Changes and Measurements

Commit Ir Delta vs baseline Check Notes
05be16b 116,554,214 -362,827 (-0.31%) cargo test --lib -- --skip tests::pnp Avoid UTF-8 conversion while appending extensions on Unix.
16c1795 114,956,513 -1,960,528 (-1.68%) cargo test --lib -- --skip tests::pnp Skip impossible bare alias checks for absolute requests.
278d640 112,025,825 -4,891,216 (-4.18%) cargo test --lib -- --skip tests::pnp Partition aliases and fallback aliases by absolute vs relative request kind.
e6517c6 109,733,110 -7,183,931 (-6.15%) cargo test --lib -- --skip tests::pnp Precheck path aliases before path-to-string conversion.

Artifacts

  • Baseline: optimization-artifacts/valgrind/callgrind/20260517T043326Z-single-thread-baseline/
  • Unix extension buffer: optimization-artifacts/valgrind/callgrind/20260517T043726Z-single-thread-unix-extension-buffer/
  • Absolute alias filter: optimization-artifacts/valgrind/callgrind/20260517T044703Z-single-thread-absolute-alias-filter/
  • Partition aliases: optimization-artifacts/valgrind/callgrind/20260517T045216Z-single-thread-partition-aliases/
  • Path alias precheck: optimization-artifacts/valgrind/callgrind/20260517T045641Z-single-thread-path-alias-precheck/
  • Final clean measurement: optimization-artifacts/valgrind/callgrind/20260517T045822Z-single-thread-final/

Test Status

cargo test --lib -- --skip tests::pnp passes (123 passed).

A full cargo test --lib still fails the existing PnP fixture cases (125 passed; 6 failed) with NotFound fixture paths. Those failures were observed before these perf changes and are tracked here as a residual environment/fixture gap, not as a new regression from this branch.

Status

Target achieved for exact resolver[single-thread]: 109,733,110 Ir is 6.15% below the clean baseline.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 17, 2026

Merging this PR will improve performance by 9.94%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
✅ 7 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation resolver[[single-threaded]resolve with many extensions] 147.2 ms 141.4 ms +4.08%
Simulation resolver[multi-thread] 65.1 ms 61.5 ms +5.91%
Simulation resolver[resolve from symlinks] 195.6 ms 172.2 ms +13.58%
Simulation resolver[single-thread] 56.9 ms 54 ms +5.43%
Simulation resolver[resolve from symlinks multi thread] 123.7 ms 101.7 ms +21.67%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing perf/micro-optimize-resolver (91e539f) with main (8975e38)

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