Skip to content

[codex] speed up non-PnP resolve#223

Draft
hardfist wants to merge 1 commit into
mainfrom
perf/micro-opt-resolve
Draft

[codex] speed up non-PnP resolve#223
hardfist wants to merge 1 commit into
mainfrom
perf/micro-opt-resolve

Conversation

@hardfist
Copy link
Copy Markdown
Contributor

Summary

  • use an exact-path cache for non-PnP resolver instances to avoid repeated semantic path hashing
  • bypass tokio::fs blocking handoff on current-thread runtimes while keeping multithreaded behavior unchanged

Why

The single-thread resolver benchmark was spending a measurable amount of time in path-cache hashing and Tokio fs handoff overhead. These changes keep PnP-enabled behavior on the existing path while optimizing the non-PnP hot path used by the benchmark.

Impact

  • faster non-PnP module resolution in the current-thread benchmark path
  • no intended behavior change for PnP-enabled resolution

Validation

  • cargo clippy --all-features -- -D warnings
  • cargo fmt --check
  • cargo test still has the same 6 pre-existing PnP failures observed on origin/main
  • CodSpeed simulation baseline: resolver[single-thread] 54.77 ms, resolver[[single-threaded]resolve with many extensions] 132.01 ms
  • CodSpeed simulation final: resolver[single-thread] 39.85 ms (-27.24%), resolver[[single-threaded]resolve with many extensions] 124.84 ms (-5.43%)

Artifacts

  • baseline: optimization-artifacts/codspeed/20260518-223013-baseline2/run.log
  • final: optimization-artifacts/codspeed/20260518-223853-exact-cache-plus-direct-fs/run.log

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 18, 2026

Merging this PR will improve performance by 7.71%

⚡ 5 improved benchmarks
❌ 2 regressed benchmarks
✅ 5 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory resolver[[single-threaded]resolve with many extensions] 12.8 MB 13.4 MB -4.48%
Memory resolver[resolve from symlinks] 12 MB 12.9 MB -7.09%
Simulation resolver[multi-thread] 62.6 ms 60.7 ms +3.04%
Simulation resolver[[single-threaded]resolve with many extensions] 143.5 ms 133.1 ms +7.83%
Simulation resolver[resolve from symlinks multi thread] 114.9 ms 103.1 ms +11.41%
Simulation resolver[resolve from symlinks] 186.2 ms 167.6 ms +11.08%
Simulation resolver[single-thread] 55.9 ms 40.6 ms +37.85%

Tip

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


Comparing perf/micro-opt-resolve (1dd4c48) with main (0616bdc)

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