Skip to content

Conversation

@ChayimFriedman2
Copy link
Contributor

This saves an enormous amount of time and memory, as described in #t-compiler/rust-analyzer > Non-copy types for the solver.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 17, 2025
Copy link
Member

@ShoyuVanilla ShoyuVanilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's second time I'm looking into this code and it became a bit simpler as it has been split into some other relatively simple PRs 😄

Looks good to me 👍 Awesome work. I'm really waiting for this to be released.

@ChayimFriedman2
Copy link
Contributor Author

Given the volume and unsafety of the changes, I'd like a second approving eye before merging this.

That means stop using Salsa for interning solver types.
A GC is triggered every X revisions, and is synchronous, unfortunately.
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reviewing but I'd love docs for the intern crate stuff

/// which will usually end up causing a bunch of incorrect diagnostics on startup.
pub(crate) incomplete_crate_graph: bool,

pub(crate) revisions_until_next_gc: usize,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up thing I'd love is if we could queue up clears on a time basis as well, like notice no (lsp) inputs where given in the last 10 seconds or so, and then hit it, to reduce the pause times we might get from user inputs

Copy link
Contributor Author

@ChayimFriedman2 ChayimFriedman2 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'll be hard to do given that GC is blocking and other operations accessing the database cannot run in parallel to it. And I'm not sure that's needed either; on omicron, a repo with lots of types (far more than r-a, for instance), at the end of analysis-stats, involving a lot more types than regular IDE experience (inferring all bodies), GC completed in under a second on my machine.

Anyway I don't want to do this in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not for this PR to make this clear, and this is also something ive wanted to do for general salsa LRU eviction. This completing in less than a second is the wrong metric though, the important bit is that this should on average (in an ideal world) complete in 10ms or less, otherwise this blocks typing noticably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, that's why I emphasized that this is a lot more types than usual. FWIW I tested r-a in the editor with GC set for every revision, and it was snappy.

@Veykril
Copy link
Member

Veykril commented Dec 18, 2025

Sorry for the split reviews, not a fan of githubs review experience here at all ...

Anyways I'd definitely love more documentation on the underlying machinery, its a complex unsafe system so docs are really needed here

@ChayimFriedman2
Copy link
Contributor Author

Yeah, I agree we need more docs on this.

@ChayimFriedman2
Copy link
Contributor Author

@Veykril I added a third commit with an extensive documentation for the unsafe stuff.

Comment on lines +20 to +22
//! Making mistakes is hard due to GC [`InternedRef`] wrappers not implementing `salsa::Update`, meaning
//! Salsa will ensure you do not store them in queries or Salsa-interneds. However it's still *possible*
//! without unsafe code (for example, by storing them in a `static`), which is why triggering GC is unsafe.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the lifetime of the InternedRef was an actually used lifetime then the static (and by extension thread locals) issue wouldn't be a problem I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants