Open zabi-haz opened 1 year ago
Rust analyzer needs to analyze everything from scratch every time you launch it. See also https://github.com/rust-lang/rust-analyzer/issues/4712 You might want to try https://github.com/pr2502/ra-multiplex to allow reusing the same rust analyzer instance when closing and re-opening (n)vim.
Are you saying it's taking longer than the previous version?
Do you have a hhd if yes, Then one possible explanation could be that their might be going some disk io (copying other hhd stuff) going in the background.
I will advice you to try to check it again and if the problem is still there.
Then providing your config would be great
Setting "rust-analyzer.cachePriming.enable": false
will also make RA appear to start faster. But it's not clear if this is a recent regression or not.
yes
Are you saying it's taking longer than the previous version?
yes
Do you have a hhd if yes, Then one possible explanation could be that their might be going some disk io (copying other hhd stuff) going in the background.
I will advice you to try to check it again and if the problem is still there.
Then providing your config would be great
no I'm using nvme storage device and its fast
rust-analyzer take to much time to lunch like 30s
found this report because I have to wait around ten minutes for the rust-analyzer to be ready every time I continue working on a project. I work on a small, portable laptop that's usually turned off and my project files are on external drives that don't stay connected to it, especially if I carry it around.
Is ten minutes reasonable? I understand that my 4 core intel atom x5-Z8350 CPU @ 1.44GHz with 4GB RAM is not a gaming rig, but I thought it was sufficient for coding... maybe I'm wrong.
Is rust-analyzer designed for fast computers or might something else be the culprit here?
@s-mayrh that's a very slow CPU of around 2 W TDP. Everything is going to be slow there, including cargo or a Web browser.
That said, how exactly are you measuring, and what OS are you running?
@lnicola I have only just noticed that these waiting times, which are already measurable in this order of magnitude with a glance at the clock, are unusual.
it's a windows 10 tablet/laptop hybrid (lenovo miix 310-10ICR). in everyday life - when i'm not compiling rust code - i still have firefox with 30 open tabs, thunderbird, libreoffice and 2 instances of signal open at the same time, but haven't noticed any noticeable delays or other slowdowns so far.
my other - the linux "desktop computer" - is a raspberry 4 with 8 gb ram on 2 ghz, which is a bit faster, but now that i read that for other people 30 seconds wait time is already long, i wonder if i have grossly overestimated my expectations, after all 1.4 ghz and 4 gb ram didn't seem inconclusive to me for "conventional" programming tasks and i've been more focused on power consumption so far.
i didn't seem to notice that the cpu requirements for programming tasks have increased so much compared to the past - or that atom and arm cpu are a no-no for rust. if that's the case, it will probably make sense to get a normal headless pc at home that runs on demand to run rust-analyzer, as well as the compiler there dedicated. does that make sense or how would you do it?
How do you know it finished loading? And is it using bevy? I noticed the issue where you were saying it takes one hour to build, which seems about right on that CPU (I imagine Unreal Engine will take about the same).
@lnicola vscode displays an animated throbber next to 'rust-analyzer' in its status bar
and indeed i'm practicing a bevy tutorial project which in it's current state is equal to this code here: https://github.com/frederickjjoubert/bevy-ball-game/tree/Episode-7
cold compile of bevy takes even two hours. i only started to question my laptop's performance when adding 'rand' to my project caused this ominous one hour of compile time.
i'm curious how other digital nomads are doing this? because i also consider renting a virtual server for such cpu heavy stuff now 🤔
You can disable cache priming in the settings. The status bar might say "indexing", but RA is fully working by that time.
Bevy is pretty large, probably comparable to Unreal Engine. And you might be hitting swap too, I don't know. I suspect most people who travel like that will have an Ultrabook-class device, or a MacBook. These are an order of magnitude faster than your 4 W CPU.
I've recently had the opportunity to use my laptop at 0.875 W, it was a memorable experience, and not in a good way.
Ping @s-mayrh did you try disabling rust-analyzer.cachePriming.enable
?
@lnicola i just disabled this via vscode settings and restarted. this is what I saw the first 8 minutes:
rust-analyzer
with animated throbber, sometimes it also shows Fetching: metadata
, less often Indexing
.
after that the throbber is gone, but it took another two minutes until tooltip and autocomplete were working. until then i just had Loading...
in them. In total it took 10 minutes again.
memory usage was almost constant [edit] during [/edit] this process 3.0/4.0 GB with a constant 228 MB swapped out. There was no swapping, just 100% cpu time
@lnicola i just disabled this via vscode settings and restarted. this is what I saw the first 8 minutes:
rust-analyzer
with animated throbber, sometimes it also showsFetching: metadata
, less oftenIndexing
.after that the throbber is gone, but it took another two minutes until tooltip and autocomplete were working. until then i just had
Loading...
in them. In total it took 10 minutes again.
I too have this issue. Have been using VSCode with various languages and plugins, never any issues. But the rust-analyzer takes at least 5 minutes to load...
@hapiel what exactly are you seeing, and are you working on some blockchain codebase?
I'm seeing this:
I'm not working on blockchain stuff. The only crate I've installed is whiskers and its dependencies.
If it's https://github.com/hapiel/genuary24_rust/blob/master/day05_vera_molnar/Cargo.toml, then you have about 800 crates in your dependency tree. A cargo check
took 23 seconds on my 5950X.
rust-analyzer runs the builds scripts when loading the project, which means building at least part of that (they're reported in the status bar). On my computer (with check
and cache priming disabled), after an initial cargo check; cargo clean
(which has to download the crates), building the proc macros takes about 4 seconds, then it becomes usable in about 10 seconds. When opening it a second time, the proc macros are already built, so it's just those ~10 seconds.
Most of that time seems to be spent in proc macro expansion (or the syntax bridge).
TL;DR, your project is not small at all, but if RA is significantly slow when opening it a second time, it might be worth looking into.
I see, the project is indeed pretty big then. Indeed that was the project I was working on. I did a few restarts of VSCode and it was back to only a minute or two, so figured all was good, but now that I reboot my computer (or I opened another project (same crates), maybe that's what triggered it?) I'm back to the 5 minutes of loading RA. Is there anything I should be caching, that I might not?
Running on a i5-8250u, 1.6Ghz, 4 core, not fast but usually not slow either.
That's a 15 W TDP CPU compared to my 105 W one, it's not going to be as fast. You can speed it up a little by disabling rust-analyzer.checkOnSave
and rust-analyzer.cachePriming.enable
, but it's probably not going to help in your case. Are you still seeing "Fetching" in the status bar?
I might be biased because I've got 5950X as well but I also have 2-in-1 HP with 8250u. It can be configured to 25W TDP but still its terribly slow for anything other than office work. This poor CPU is struggling to keep up when just browsing the web
@mati865 wait until you see my 0.875 W PL1 1260P :-).
rust-analyzer take to much time to lunch like 30s
hi there,
I"m using neovim, and i installed rust-analyzer with aur(arch user repo (AUR :: like store but for arch-artix linux),
and i install rust analyzer with mason and nvim lsp
it takes way to long to lunch the last version was fast to lunch this is a new problem with me
this is my laptop specks
CPU: Intel i5-7300U (4) @ 3.500GHz GPU: Intel HD Graphics 620 Memory: 7689MiB
neovim version is 0.8.3
rust-analyzer version is :
rust-analyzer 0.0.0 (0a956ec93 2023-03-05)