Bevy should become less of a rust-analyzer stress test
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
I first observed this working from 1a410efd246e0f2f41766d47e300f474c8379b2e but I believe it remains relevant today, 3 days later.
## What you did
I tried to edit a file in Bevy. Specifically, `crates/bevy_reflect/src/lib.rs`. I was trying to remove some of the glob imports, so I used rust-analyzer's expand-glob-imports assist.
## What went wrong
Honestly I was expecting things to be slow. But I encountered outright pathological behavior from rust-analyzer, as it hung after every "unglob". See https://github.com/rust-lang/rust-analyzer/issues/20173 for more on why, but the details here are that while the glob assist worked fine, it happened to perturb the state of the file enough that rust-analyzer recomputed the diagnostics for the entire file, including every glob import.
This happens to be pretty slow, and I believe it scales with the number of globs, possibly nonlinearly? I don't know what else can trigger it except this assist, but I believe it is **not unique** to that assist, i.e. other things can cause diagnostics to be recomputed. It probably just depends on how much the file changes.
## Additional information
My understanding of the rust-analyzer architectural issues is that, while we can expect this to speed up ~soon, rust-analyzer still handles globs extremely poorly and will have other correctness and performance issues.
I believe rust-analyzer's team will be able to extract a number of very useful benchmarks and tests from the historical information available in Bevy's repo. Meanwhile, Bevy should, on future commits, reduce the amount of patterns it uses that are outright problematic for performance in That Other Rust Compiler People Use.
Contributor guide
Research direction
Start with crates/bevy_reflect/src/lib.rs and the linked rust-analyzer issue; inventory the glob imports and identify which patterns are implicated in slow diagnostics. Done means a focused Bevy change reduces problematic glob usage and the behavior can be checked without pathological rust-analyzer hangs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100