rust-lang / rust-lang/rust-analyzer
enabled a lens config CodeAction is very slow
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 version: rust-analyzer 1.82.0-nightly (7c2012d0 2024-07-26)
rustc version: rustc 1.82.0-nightly (7c2012d0e 2024-07-26)
editor or extension: Vim 9.1 coc-rust-analyzer
relevant settings:
{
"rust-analyzer.updates.checkOnStartup": false,
"rust-analyzer.lens.references.method.enable": true
}
code snippet to reproduce src/main.rs:
use std::{fmt::Display, ops::Deref};
#[derive(Debug, Clone, Eq)]
pub enum ParseLine<'a> {
Label(&'a str),
Args((), u32),
}
impl<'a> PartialEq for ParseLine<'a> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Label(l0), Self::Label(r0)) => l0 == r0,
(Self::Args(l0, _), Self::Args(r0, _)) => l0 == r0,
_ => false,
}
}
}
impl<'a> TryFrom<Vec<&'a str>> for ParseLine<'a> {
type Error = ();
fn try_from(_: Vec<&'a str>) -> Result<Self, Self::Error> {
Ok(Self::Args((), 0))
}
}
impl<'a> From<&'a str> for ParseLine<'a> {
fn from(_: &'a str) -> Self {
todo!()
}
}
impl<'a> From<()> for ParseLine<'a> {
fn from(_: ()) -> Self {
todo!()
}
}
impl<'a> Display for ParseLine<'a> {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
fn main() { }
reproduce steps:
- open file
src/main.rs, CPU Usage to 400%, Memory Usage to 851 MB - in line 11
=> l0start CodeAction, is slow - any edit and save file, and start CodeAction is very slow, Max CPU Usage to 700%, Memory Usage to 1350 MB
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 the reproduction in src/main.rs, especially the CodeAction at line 11 and the reported rust-analyzer settings. Reproduce the action before and after editing and saving, then investigate the excessive CPU and memory usage. Done means the CodeAction no longer becomes very slow or reaches the reported resource usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, vim
- Domain
- devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100