Skip to content

Compiler Lecture: How Salsa works #401

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

Closed
wants to merge 3 commits into from
Closed

Compiler Lecture: How Salsa works #401

wants to merge 3 commits into from

Conversation

Karrq
Copy link

@Karrq Karrq commented Jul 26, 2019

#355

cc @spastorino

Some questions left regarding content (see footnotes).

Other doubts (from me):

  • Should this be put in another section in the summary, and group other compiler lectures there?
  • Comparing this to the other chapter that talk about incremental computation this chapter is pretty high-level and talks about a feature external to the compiler (AFAIK it hasn't been integrated in the compiler yet), does it belong here, in the rustc-guide?

@spastorino
Copy link
Member

Would be great if @nikomatsakis can also review this :)

After the database is formed, it can be accessed with queries that are basically going to work like functions.
Since each query is going to be stored in the database, when a query is invoked N times, it's going to return N **cloned** results, without having to recompute the query (unless the input has changed in such a way that it warrants recomputation).

For each input query (0-key), there's going to be a "set" method, that allows to change the output of such query, and trigger previous memoized values to be potentially invalidated.
Copy link
Member

Choose a reason for hiding this comment

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

All of the "going to be" phrasing makes it sound like these are features that Salsa could have in the future, but doesn't currently. I'd review the text to phrase it in the present tense.

Copy link
Author

Choose a reason for hiding this comment

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

If you are talking about this section specifically, it's because this refers to something that's going to happen when the library is used... If talking about the whole article: the text is based of a video done a while ago, some stuff might not had yet been implemented by that point. I don't know what's in salsa now so I can't really tell if something should be on the present tense. Either way, I decided to rewrite this section a bit with present tense as you suggested

Karrq and others added 2 commits July 28, 2019 19:10
@mark-i-m
Copy link
Member

@Karrq sorry for the delay. I will try to get to this soon.

Copy link
Member

@mark-i-m mark-i-m left a comment

Choose a reason for hiding this comment

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

@Karrq Thanks so much for your patience and hard work!

This looks good to me. If you are able to address the nits below, that would be great. If you don't have time/interest, then I can just merge and do that in a followup PR.


The first thing that Salsa has to do is identify the "base inputs" [^EN1].

Then Salsa has to also identify intermidiate, "derived" values, which are something that the library produces, but, for each derived value there's a "pure" function that computes the derived value.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Then Salsa has to also identify intermidiate, "derived" values, which are something that the library produces, but, for each derived value there's a "pure" function that computes the derived value.
Then Salsa has to also identify intermediate, "derived" values, which are something that the library produces, but, for each derived value there's a "pure" function that computes the derived value.

@@ -31,6 +31,7 @@
- [The Query Evaluation Model in Detail](./queries/query-evaluation-model-in-detail.md)
- [Incremental compilation](./queries/incremental-compilation.md)
- [Incremental compilation In Detail](./queries/incremental-compilation-in-detail.md)
- [How Salsa works](./compiler_lectures/how_salsa_works.md)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps move this after the debugging subchapter?


## What is Salsa?

Salsa is a library for incremental recomputation, this means reusing computation that has already been done in the past to increase the efficiency of future computations.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps add a note that it is not used directly in rustc, but it is used extensively for rust-analyzer and may be integrated into the compiler in the future

Copy link
Member

Choose a reason for hiding this comment

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

Exactly what @mark-i-m is mentioning here is what I was going to ask :).

@mark-i-m
Copy link
Member

Oh, also, could you wrap the lines to 100 chars? That will appease the CI.

@spastorino
Copy link
Member

spastorino commented Nov 14, 2019

This is good enough, I saw some parts that mention something about inaudible parts of the video, I'm not sure what you plan to do with those. If we can get rid of those with something that still makes sense I think it would be better.

Anyway, also agreed with @mark-i-m, thanks for your hard work and this is good enough to merge if you prefer to fix the nits in a follow up or just have us figuring those out :).

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