rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Load files into the VFS in parallel on startup

Open Veykril opened this issue 1 year ago • 2 comments

We currently load them from a single thread which can make startup very slow for bigger projects as we re-query the project layout over and over again until all files are loaded (this is a separate issue that we should fix, that is wait with that until all files are loaded into memory).

Veykril avatar Jun 09 '24 09:06 Veykril

For some additional context from Zulip, the current single-threaded loading behavior is especially problematic on EdenFS, which really wants tooling to send as many IO requests as possible in parallel.

davidbarsky avatar Jun 10 '24 13:06 davidbarsky

this is a separate issue that we should fix, that is wait with that until all files are loaded into memory.

I did some rough, back-of-napkin benchmarking on this: rust-analyzer spends 5 seconds waiting on rustc for every 100 crates it loads (just printed Instant::elapsed::as_millis...). Given that total crate dependency graphs of over 1000 are not uncommon for larger Rust projects in the wild, it's likely that people are unnecessarily waiting for over a minute.

What makes this fix a little more complicated is that during project loading, there isn't a clear end-state: rust-analyzer just sorta repeatedly calls GlobalState::fetch_workspaces.

davidbarsky avatar Jun 11 '24 21:06 davidbarsky

Is this done via #17771 or needs extra works? I think that we are still loading project root files on startup in a single thread but I haven't tested yet whether it take much time or not.

ShoyuVanilla avatar Dec 05 '24 23:12 ShoyuVanilla

Yes we still need to do the initial loading in parallel

Veykril avatar Dec 06 '24 04:12 Veykril