Skip to content

internal: Make use of salsa's new NEVER_CHANGE durability#22638

Draft
Veykril wants to merge 3 commits into
rust-lang:masterfrom
Veykril:veykril/push-nyrpmrqyuqwz
Draft

internal: Make use of salsa's new NEVER_CHANGE durability#22638
Veykril wants to merge 3 commits into
rust-lang:masterfrom
Veykril:veykril/push-nyrpmrqyuqwz

Conversation

@Veykril

@Veykril Veykril commented Jun 25, 2026

Copy link
Copy Markdown
Member

No description provided.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 25, 2026
@Veykril Veykril mentioned this pull request Jun 25, 2026
Comment thread crates/base-db/src/lib.rs Outdated
) {
match self.files.entry(file_id) {
Entry::Occupied(mut occupied) => {
Entry::Occupied(mut occupied) if durability != Durability::NEVER_CHANGE => {

@MichaReiser MichaReiser Jun 25, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ignoring the write seems a bit suspicious. Isn't it desired to panic here and, instead, either fix the durability for the file if it is NEVER_CHANGE and can change, or change the call site not to call set_file_text_with_durability for such a fiel?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are not wrong, but our file setup is kind of convoluted so I don't even know if we can reliably do that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In fact yea then we'd need to do the filtering somewhere else as we do track changes to these files (which arguably we shouldn't register file watchers for I think)

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

If this has the same disadvantage as my old branch, namely that it cannot reload changed features in dependencies correctly, then I oppose to that. We're not at the same place we were at the time wrt. memory usage, and today I think this is not worth the code complexity and workflow disruption.

@MichaReiser

Copy link
Copy Markdown

In ty, we only use it for fields that are truly immutable. That is, we vendor some files, so they can never change. Each file has a path, and the path can never change (it's its identity).

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

We don't have such things, but we do have std which I suppose we can assume never changes. It won't be a big win, but given this is already in Salsa I guess it could be worth it.

@Veykril

Veykril commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

But we do? Any file in the local crate registry as well as the standard library we can assume to be never changing. That's what this PR is doing. Aside from that I agree, there isn't really anything else (aside from some source roots in theory maybe?).

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

No, like I said back then, changing Cargo features (or cfgs) can change the analysis on those files, even if their content doesn't change.

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

I see now that you don't mark the Crate itself as NEVER_CHANGE, only the file text, so I believe it should work but the memory saving will be vanishingly small.

@Veykril

Veykril commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Yea, trusting the analysis stats run here its ~4mb on self. Not great but might as well try. I do want to check out how much using on a crate would save (just out of curiosity), its a shame we can't actually do that.

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Do note that this is not completely enough, you also need to make the expand_proc_attr_macros() setting NEVER_CHANGE.

@Veykril Veykril marked this pull request as draft June 26, 2026 10:33
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants