Skip to content

Disable indexing every crate in workspace while only one crate is opened. #10669

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
jkelleyrtp opened this issue Oct 30, 2021 · 12 comments
Closed
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@jkelleyrtp
Copy link
Contributor

jkelleyrtp commented Oct 30, 2021

I'm not sure if there's a setting anywhere, but every time I open an individual crate in a workspace, Rust-analyzer indexes every single dependency that every crate has (1200+ crates just for a tiny crate in the workspace). Save/Reloading takes forever.

Is there a way to disable this?

@lnicola
Copy link
Member

lnicola commented Oct 31, 2021

I'm not sure if there's a setting anywhere, but every time I open an individual crate in a workspace

The indexing step should only happen once per start-up. Is that a Code workspace with Rust and maybe other languages?

Save/Reloading takes forever.

That's probably running cargo check. You can disable that, but you'll lose the rustc diagnostics.

@oeed
Copy link
Contributor

oeed commented Nov 10, 2021

You could take a look at #8362, I encountered similar issues - although not that many crates.

@jkelleyrtp
Copy link
Contributor Author

Closed by #10743

@jkelleyrtp
Copy link
Contributor Author

Actually - not quite closed. Fewer crates are being indexed in workspaces, but RA still indexes transitive dependencies of other crates in the workspace even if only one smaller crate is open.

@lnicola
Copy link
Member

lnicola commented Nov 16, 2021

Fewer crates are being indexed in workspaces, but RA still indexes transitive dependencies of other crates in the workspace even if only one smaller crate is open.

I think we do that to.. have finer progress reporting doing the cache priming? CC @jonas-schievink

@jonas-schievink
Copy link
Contributor

We do that so that when you open another workspace file, its dependencies are already processed and you get IDE features quickly. We could make indexing aware of the set of opened files, but I'm not sure if that is a good idea.

Note that indexing won't impede IDE usage in files that already have all necessary data available, and it should also never prevent you from saving or closing files, or from switching to another workspace. If it does that, that's a separate bug.

@lnicola
Copy link
Member

lnicola commented Nov 16, 2021

But what if we ran it only for the crates in the workspace, without their dependencies? In an eyeball test, it seems to finish in about 7 s instead of 8.

Do we want to run the priming on e.g. instant just because there's a base_db -> salsa -> parking_lot -> parking_lot_core -> instant dependency chain?


Looking at the CPU time with no open files, there doesn't seem to be a large difference, but the memory usage is slightly lower (541 MB vs. 558 MB).

@jkelleyrtp
Copy link
Contributor Author

jkelleyrtp commented Nov 16, 2021

I opened this particular issue because every time I open a tiny crate in my workspace (>30 total deps), RA starts to index a bunch of crates (1200 before, 300 now) and my battery life drains / laptop gets real toasty. It would be convenient to have a way to disable indexing of other workspace crates that aren't dependencies of the opened crate to save battery life.

@lnicola
Copy link
Member

lnicola commented Nov 16, 2021

Yeah, ideally the priming would be configurable. Without it, the first requests will be visibly slower, but less likely to spin up your fans. In Code you'll get a limited version of the priming anyway because the semantic highlighting and inlay hints end up doing the same thing.

@jonas-schievink
Copy link
Contributor

Do we want to run the priming on e.g. instant just because there's a base_db -> salsa -> parking_lot -> parking_lot_core -> instant dependency chain?

Ah, yeah, we do use transitive dependencies here to provide better progress. We can definitely play around with just not doing that, if it helps.

@Veykril Veykril added the S-actionable Someone could pick this issue up and work on it right now label Dec 4, 2021
@lnicola
Copy link
Member

lnicola commented Dec 11, 2021

#10978 should have helped here, but #10810 added a preference to disable cache priming. I think this can be closed now.

@lnicola lnicola closed this as completed Dec 11, 2021
@jkelleyrtp
Copy link
Contributor Author

Not sure if this has been fixed since 2021 or if it recently became an issue, but the issue has returned (or never went away?) and editing in vscode with large workspaces is frustratingly slow. I use very few extensions (RA + Github Copilot + GitLens + ErrorLens).

Any time I save, VSCode freezes and stutters while RA is printing out dozens of crates in the workspace that I'm not actively editing.

I have an M1 so I'm certain my machine is not too slow.

Screen.Recording.2022-10-02.at.3.27.30.PM.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants