rust-lang / rust-lang/rust-analyzer
`find_path` blows up exponentially
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
In the project that can't be shared publicly rust-analyzer started hanging up all worker threads within find_path_module / calculate_best_path. I assume that it is not actually hanging (as the recursion does look like having appropriate exit conditions everywhere) but instead running into a search tree so wide that with a max depth of 15 (https://github.com/rust-lang/rust-analyzer/blob/cdb4f9631c88be66fc0ea84700f334600ace4a67/crates/hir-def/src/find_path.rs#L48) we just run into too much work to do depending on the project setup. Lowering that to 5 seemed to somewhat fix the issue in the project somewhat confirming my assumption
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crates/hir-def/src/find_path.rs, especially the max-depth setting near line 48 and the find_path_module/calculate_best_path entry points. Investigate the reported exponential search behavior and compare the effect of the depth limit; the private project cannot be used as a public reproduction, so completion requires a validated fix or regression coverage for excessive work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100