Skip to content

chore: Start infesting ide crates with 'db lifetime #19495

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Apr 1, 2025

Got curious what this would look like, results in a bit of lifetime infestation :)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 1, 2025
@Veykril Veykril force-pushed the push-woywmrxrtqqy branch from 22e5376 to da797a6 Compare April 1, 2025 10:00
@Veykril Veykril changed the title chore: Remove unnecessary Arc clones refactor: Intern TraitEnvironment into salsa Apr 1, 2025
@ChayimFriedman2
Copy link
Contributor

I would not merge this until we determine the effect on performance.

@Veykril
Copy link
Member Author

Veykril commented Apr 1, 2025

analysis-stats for me varied by ~1% so very much within noise on my machine.

@ChayimFriedman2
Copy link
Contributor

Did we even intern TraitEnvironment previously? And do we really need the fine-grained tracking here?

@Veykril Veykril force-pushed the push-woywmrxrtqqy branch from da797a6 to f0f1486 Compare April 1, 2025 10:20
@Veykril
Copy link
Member Author

Veykril commented Apr 1, 2025

Did we even intern TraitEnvironment previously?

No, I got partially curious if we would gain something from it being interned. It doesn't look like it though. (Technically hir::Type would become copy with this when we switch to the new trait solver)

And do we really need the fine-grained tracking here?

There is no fine grained tracking here really given its an interned struct, not tracked one.

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Apr 1, 2025

There is no fine grained tracking here really given its an interned struct, not tracked one.

Are you sure? I think interned structs also have fine grained tracking.

Edit: It seems you're right, there's no fine grained tracking.

@Veykril Veykril marked this pull request as draft April 1, 2025 10:25
@ChayimFriedman2
Copy link
Contributor

(Technically hir::Type would become copy with this when we switch to the new trait solver)

How so? We'll need to intern Ty for that too (and I'm completely not sure it's worth it)

@Veykril Veykril force-pushed the push-woywmrxrtqqy branch from f0f1486 to 78b5c6e Compare April 1, 2025 10:29
@Veykril
Copy link
Member Author

Veykril commented Apr 1, 2025

(Technically hir::Type would become copy with this when we switch to the new trait solver)

How so? We'll need to intern Ty for that too (and I'm completely not sure it's worth it)

From what I understood, we will be interning the type-ir Ty's within salsa such that we get copy-able handles which is a hard requirement by the new solver.

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Apr 1, 2025

(Technically hir::Type would become copy with this when we switch to the new trait solver)

How so? We'll need to intern Ty for that too (and I'm completely not sure it's worth it)

From what I understood, we will be interning the type-ir Ty's within salsa such that we get copy-able handles which is a hard requirement by the new solver.

Didn't @jackh726 relax this requirement?

@Veykril
Copy link
Member Author

Veykril commented Apr 1, 2025

Anyways this doesn't seem too useful, though I am inclined to include the 'db changes as this will have to occur at some point anyways the further we move into new salsa

@davidbarsky
Copy link
Contributor

(Technically hir::Type would become copy with this when we switch to the new trait solver)

How so? We'll need to intern Ty for that too (and I'm completely not sure it's worth it)

From what I understood, we will be interning the type-ir Ty's within salsa such that we get copy-able handles which is a hard requirement by the new solver.

Didn't @jackh726 relax this requirement?

To some degree, but not really. I still think we should do copy-able handles if possible.

Does this have a memory usage impact, out of curiosity?

@Veykril Veykril force-pushed the push-woywmrxrtqqy branch from 78b5c6e to 9fffec4 Compare April 5, 2025 13:15
@Veykril
Copy link
Member Author

Veykril commented Apr 5, 2025

Looks like this doesnt save memory (2MB) but it is apparently faster? 10 seconds speedup for type inference on CI which I wouldn't classify as within noise https://github.com/rust-lang/rust-analyzer/actions/runs/14282272667/job/40033194279?pr=19495 vs https://github.com/rust-lang/rust-analyzer/actions/runs/14282156180/job/40032940941

@davidbarsky
Copy link
Contributor

Alright, nice! Maybe we should land this, since it could make Jack's life easier: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Implmentating.20New.20Trait.20Solver/near/510313582

@Veykril
Copy link
Member Author

Veykril commented Apr 5, 2025

Ah wait, forget that. We can't really take the numbers there seriously I think as those are debug builds (and they do seem to vary a lot). That is only memory usage there is sensible.

@Veykril Veykril force-pushed the push-woywmrxrtqqy branch from 9fffec4 to 03c8508 Compare April 7, 2025 11:03
@Veykril Veykril changed the title refactor: Intern TraitEnvironment into salsa chore: Start infesting ide crates with 'db lifetime Apr 7, 2025
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.

None yet

4 participants