-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Make Module a Salsa ingredient
#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
Conversation
|
@MichaReiser RE #19408 (comment) What would be the downside of leaving |
|
|
|
I'm curious, given that |
MichaReiser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the downside of leaving Module as it was and not making it an ingredient? I
The main downside is that all_submodule_names requires the () dummy argument because its (otherwise) only argument (self) isn't a salsa ingredient. What this does behind the scene is that salsa creates an ad-hoc interned struct with two fields: dummy: () and module: self.
I'm curious, given that File:Module is 1:1, why we need to make queries cache based on Module instead of based on its File? AFAIK we've mostly just based everything around File.
I must admit, I didn't look at all_submodule_names in detail and you're right, we could restructure that function so that only the portion operating on File would be the salsa query. That would remove the need to make Module a salsa query today.
It being a salsa struct would still be beneficial if we need queries operating on namespace packages or queries using other Module fields that can't be as easily restructured as all_submodule_names.
@BurntSushi has probably more insight here on whether we want to extend all_submodule_names to namespace packages in the future or if there are other queries that need to operate at the module level
We want to write queries that depend on `Module` for caching. While it seems it can be done without making `Module` an ingredient, it seems it is best practice to do so. [best practice to do so]: #19408 (comment)
This makes caching of submodules independent of whether `Module` is itself a Salsa ingredient. In fact, this makes the work done in the prior commit superfluous. But we're possibly keeping it as an ingredient for now since it's a bit of a tedious change and we might need it in the near future. Ref #19495 (review)
1ab706b to
a5e21ef
Compare
I am not 100% certain about this, but I suspect so. I'm thinking about queries for symbols exported by modules (for auto import). If I'm wrong about this and I've pushed up another commit that does restructure the code to just use |
Makes sense. The main question is if they could be over |
Changes which I chose not to include; let me know if one of these should be added: ``` - Add warning for unknown `TY_MEMORY_REPORT` value ([#19465](astral-sh/ruff#19465)) - Add goto definition to playground ([#19425](astral-sh/ruff#19425)) - Added support for "go to references" in ty playground. ([#19516](astral-sh/ruff#19516)) - Fall back to `Unknown` if no type is stored for an expression ([#19517](astral-sh/ruff#19517)) - Make `Module` a Salsa ingredient ([#19495](astral-sh/ruff#19495)) - Return a tuple spec from the iterator protocol ([#19496](astral-sh/ruff#19496)) ``` --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This makes caching of submodules independent of whether `Module` is itself a Salsa ingredient. In fact, this makes the work done in the prior commit superfluous. But we're possibly keeping it as an ingredient for now since it's a bit of a tedious change and we might need it in the near future. Ref #19495 (review)
Changes which I chose not to include; let me know if one of these should be added: ``` - Add warning for unknown `TY_MEMORY_REPORT` value ([#19465](astral-sh/ruff#19465)) - Add goto definition to playground ([#19425](astral-sh/ruff#19425)) - Added support for "go to references" in ty playground. ([#19516](astral-sh/ruff#19516)) - Fall back to `Unknown` if no type is stored for an expression ([#19517](astral-sh/ruff#19517)) - Make `Module` a Salsa ingredient ([#19495](astral-sh/ruff#19495)) - Return a tuple spec from the iterator protocol ([#19496](astral-sh/ruff#19496)) ``` --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
We want to write queries that depend on
Modulefor caching. While itseems it can be done without making
Modulean ingredient, it seems itis best practice to do so.