-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
internal: port rust-analyzer to new Salsa #18964
Draft
davidbarsky
wants to merge
19
commits into
rust-lang:master
Choose a base branch
from
davidbarsky:davidbarsky/port-rust-analyzer-to-new-salsa
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
internal: port rust-analyzer to new Salsa #18964
davidbarsky
wants to merge
19
commits into
rust-lang:master
from
davidbarsky:davidbarsky/port-rust-analyzer-to-new-salsa
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal: remove chalk bump
This commit consists of several changes: - Reimplement `SyntaxContext` using new salsa's self-referential interning - fix `SyntaxContext`'s `StructData` Hash and PartialEq impls - fix `SyntaxContext` Debug impl - Do not store IDs of inputs in the inputs themselves - the removal of `ra-salsa`
rustbot
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Jan 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR ports rust-analyzer to the new Salsa. It is big, partially incomplete, and best reviewed commit-by-commit. I will be rebasing often.
(Why new Salsa? It unblocks a lot of work described in #17491.)
Migration Approach
To get rust-analyzer compiling and passing tests, this PR did the following:
db-ext-macro
to mimic rust-analyzer's usage of old Salsa's query groups. Over time, rust-analyzer will migrate to new Salsa's idioms, moving away from the query group pattern. For additional details on the differences between old Salsa and new Salsa, please refer to this document.crates/span
to new Salsa, which makes use of self-referential interning. This is needed to support macro hygiene.'db
lifetime. However, the presence of the'db
lifetime made migrating a large number of interned structs challenging, hence feature: add#[salsa::interned_sans_lifetime]
macro salsa-rs/salsa#632.With these changes, all tests were passing (no correctness issues!),
analysis-stats
produced the same results as rust-analyzer on the old Salsa, and—critically—the new Salsa-powered rust-analyzer was usable as my daily driver. Unfortunately, memory usage was too high. I'm really grateful to the following folks who helped fix that regression:analysis-stats
from 8 gigabytes to 4 gigabytes by through https://lgithub.com/salsa-rs/salsa/pull/614/.#[salsa::enum]
, which reduced memory usage by about 150 megabytes and made rust-analyzer's usage of new Salsa more idiomatic.Performance
rust-analyzer analysis-stats
, new Salsa is slightly slower and uses slightly more memory.crates/rust-analyzer/src/integrated_benchmarks.rs
, new Salsa is slightly faster on both cold and warm updates. These benchmarks should probably be more rigorous, but new Salsa was consistently faster.Things to Fix Before to Merging
There's a few things to do before this change is merged:
enum
/#[salsa::supertype]
commit cause tests to fail to type confusion in the underlying Salsa pages. Chayim is working on root-causing this, but if he's unable to determine the cause, I can make the enum changes a separate pull request.db-ext-macro
.db-ext-macro
to something else, or have it live in Salsa. I'm unsure which option I'd prefer right now.Acknowledgements
This wouldn't have been possible without the assistance of many folks including @ChayimFriedman2, @ShoyuVanilla, @nikomatsakis, and @Veykril. I'm sure I'm forgetting some people, to whom I apologize.