-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
A Plan for Making Rust Analyzer Faster #17491
Comments
FWIW I see parallelism fixes as strictly orthogonal. Some are blocked on salsa, but parallel crate graph loading or parallel VFS loading could happen today, and I think they could be decent performance wins. |
Regarding this, I think the original Salsa used a scan-resistant strategy (SLRU?), see rust-analyzer/crates/salsa/src/lru.rs Line 228 in ac389ce
|
Not sure I fully understand this, but if I do, then I think this is caused by the VFS being processed fairly slowly. Whenever a file gets created (or something along the lines, which is the case on start up for all files we load), we will requery the project layout. On fairly large projects the VFS just takes ages to report and be fully loaded. |
Given I'm of the opinion that the mutable API is more problematic than useful, we should definitely go for a flat structure I think. Edits / Construction of trees from multiple trees being more expensive shouldn't be a big problem I think, there is little that would care about that, assists are lazy in terms of their edits so there is no problem with that there, and aside from those not much really does tree style edits in the first place! So we should absolutely replace the current rowan -> #6584 (also to note, rowan makes heavy use of the header pattern which is unsound under SB/TB so swapping that would generally be good in that regard as well) |
I think the VFS is partly responsible, but I've come to this conclusion by through a combination of debugging this and setting I also did see a lot of
I have observed this, and while that certainly doesn't help, I think that fixing that issue would be pretty easy if it were possible for the VFS (at least during initial indexing) to read all sources at once. I wrote a small, incomplete file loader and ran it against buck2's |
Re flat syntax trees, leaving this here: https://github.com/saschagrunert/indextree. |
Some background context:
Anyways, here's non-exhaustive (but decently comprehensive!) list of things that we'd like to fix.
Non-Parallel, Single-Threaded Improvements
macro_rules!
expansion is quadratic. This most visible with tt-munchers (discussion).cargo-metadata
or arust-project.json
. Deriving the crate ID from the crate data itself (via Salsa’s interning infrastructure) will provide a stable ID (discussion on Zulip).Instant::elapsed::as_millis
). Given that some Rust projects can easily have of over 1000 dependencies, it’s possible that people are waiting for nearly a minute.Parallel Improvements
From a sequencing standpoint, most parallelism improvements in rust-analyzer should happen after single-threaded improvements occurs, as introducing parallelism without making single-core performance improvements simply papers over existing, resolvable performance issues—I believe it is better to have those improvements compound. Besides, for a large number of these changes below, are waiting on Salsa 3.0, as it will enable trivial parallel computation for all databases (salsa-rs/salsa#495) 1.
I'll add more items as they come up, but I figured I should combine the different discussion topics into a single location.
Footnotes
The version of Salsa used by rust-analyzer todays requires getting a snapshot from the
ParallelDatabase
trait, andParallelDatabase
is only implemented on theRootDatabase
. Similarly, parallel query dependencies are not legible to Salsa, which complicates the invalidation story. ↩The text was updated successfully, but these errors were encountered: