rust-lang / rust-lang/rust-analyzer

`find_path` blows up exponentially

Open
#17,339 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-perf C-bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.