Skip to content

rust-analyzer takes too much time to load a project #9271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karagenc opened this issue Jun 14, 2021 · 4 comments
Closed

rust-analyzer takes too much time to load a project #9271

karagenc opened this issue Jun 14, 2021 · 4 comments

Comments

@karagenc
Copy link

I'm using rust-analyzer version 2021-06-14 stable with Visual Studio Code. I have rust-analyzer plugin installed (the default official rust plugin is not installed).

When i open a project with Visual Studio Code, rust-analyzer takes too much time to initialize. Especially if the project is big and has a lot of dependencies it takes approximately 1 minute for intellisense to be enabled.

These 2 steps take the most time:

  • Fetching metadata
  • Indexing

I like rust-analyzer. It is a great LFS but i wish there was a cache or something because whenever i open a project i wait for a minute (sometimes a few minutes) for the intellisense.

@flodiebold
Copy link
Member

Duplicate of #1650 / #4712, unless you have a specific project where indexing takes abnormally long.

@lnicola
Copy link
Member

lnicola commented Jun 14, 2021

Also, "fetching metadata" means it's updating the cargo registry, which can take quite a while but is usually called by cargo itself.

@karagenc
Copy link
Author

karagenc commented Jun 17, 2021

Sorry for duplicate issue. I'm new to Rust and i want to write an API server. But web frameworks (warp, rocket, gotham, actix) have a lot of dependencies. Try creating a simple web server with one of these frameworks and you'll see that rust-analyzer takes more than 30 seconds to initialize.

Indexing takes too much time.

Screenshot from 2021-06-17 11-45-08

Is it a problem related to my system? Or is it common for rust-analyzer to take too much time to index such a large set of dependencies?

Also fetching metadata take a while too. Does it fetch data from a server? Is this related to my internet connection?

Other than that, rust-analyzer is awesome. Thank you for your efforts!

@lnicola
Copy link
Member

lnicola commented Jun 17, 2021

We need to run cargo metadata ("Fetching metadata") when loading the project, which can cause cargo to update its crate index (presumably if it's the first time you're compiling a project, or if the project is using a crate version that's not available locally). This is a git clone, but I've seen it take a couple of minutes.

We also run cargo check for diagnostics, proc macros and build scripts. You can disable all of these, but they happen in the background. "Indexing" is rust-analyzer itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants