rust-lang / rust-lang/rust-analyzer
Rust Analyzer formatting/checking is slow, blocks file saving and only rechecks file on save.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Rust Analyzer formatting/checking takes >600 ms when saving a file and it blocks the file from actually saving when I press CTRL+S. This is really annoying because I want to cargo run immediately after saving and I often run the old version of the code and wonder why something is broken.
It would be great if this actually didn't block saving and would let the file to be written to the disk before checking & formatting has finished, and it can be saved again when all of that is done. Especially because formatting won't impact the running of my program and cargo run will do all of the checking before compilation anyways.
I'm not exactly sure why this whole process is so slow (even on small files, this one in particular is <200 LOC) but making it faster would certainly greatly improve user experience.
It would also be great if the checking of the file (for compilation errors) would happen periodically, and not only when I save the file.
Relevant log:
...
[ERROR rust_analyzer::main_loop] overly long loop turn: 621.9104ms
...
[ERROR rust_analyzer::main_loop] overly long loop turn: 639.4545ms
...
[ERROR rust_analyzer::main_loop] overly long loop turn: 642.6391ms
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
The report points to rust_analyzer::main_loop and the save-triggered formatting/checking path; start by reproducing the >600 ms loop turns while saving a small Rust file. Trace when the file is written versus formatting and checking, then verify saving is not blocked and checking behavior matches the requested periodic updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience, devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100