Skip to content

Commit d15c82a

Browse files
Alexander Regueiromark-i-m
Alexander Regueiro
authored andcommitted
improved grammar and fixed small errors
1 parent c3eb273 commit d15c82a

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/incremental-compilation.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The incremental compilation scheme is, in essence, a surprisingly
44
simple extension to the overall query system. We'll start by describing
5-
a slightly simplified variant of the real thing, the "basic algorithm", and then describe
5+
a slightly simplified variant of the real thingthe "basic algorithm" and then describe
66
some possible improvements.
77

88
## The basic algorithm
@@ -11,8 +11,8 @@ The basic algorithm is
1111
called the **red-green** algorithm[^salsa]. The high-level idea is
1212
that, after each run of the compiler, we will save the results of all
1313
the queries that we do, as well as the **query DAG**. The
14-
**query DAG** is a [DAG] that indices which queries executed which
15-
other queries. So for example there would be an edge from a query Q1
14+
**query DAG** is a [DAG] that indexes which queries executed which
15+
other queries. So, for example, there would be an edge from a query Q1
1616
to another query Q2 if computing Q1 required computing Q2 (note that
1717
because queries cannot depend on themselves, this results in a DAG and
1818
not a general graph).
@@ -43,24 +43,23 @@ There are two key insights here:
4343

4444
### The try-mark-green algorithm
4545

46-
The core of the incremental compilation is an algorithm called
46+
At the core of incremental compilation is an algorithm called
4747
"try-mark-green". It has the job of determining the color of a given
48-
query Q (which must not yet have been executed). In cases where Q has
48+
query Q (which must not have yet been executed). In cases where Q has
4949
red inputs, determining Q's color may involve re-executing Q so that
50-
we can compare its output; but if all of Q's inputs are green, then we
51-
can determine that Q must be green without re-executing it or inspect
52-
its value what-so-ever. In the compiler, this allows us to avoid
53-
deserializing the result from disk when we don't need it, and -- in
54-
fact -- enables us to sometimes skip *serializing* the result as well
50+
we can compare its output, but if all of Q's inputs are green, then we
51+
can conclude that Q must be green without re-executing it or inspecting
52+
its value, regardless. In the compiler, this allows us to avoid
53+
deserializing the result from disk when we don't need it, and in fact
54+
enables us to sometimes skip *serializing* the result as well
5555
(see the refinements section below).
5656

5757
Try-mark-green works as follows:
5858

59-
- First check if there is the query Q was executed during the previous
60-
compilation.
59+
- First check if the query Q was executed during the previous compilation.
6160
- If not, we can just re-execute the query as normal, and assign it the
6261
color of red.
63-
- If yes, then load the 'dependent queries' that Q
62+
- If yes, then load the 'dependent queries' of Q.
6463
- If there is a saved result, then we load the `reads(Q)` vector from the
6564
query DAG. The "reads" is the set of queries that Q executed during
6665
its execution.
@@ -106,9 +105,9 @@ query `main_query` executes will be `subquery2`, and `subquery3` will
106105
not be executed at all.
107106

108107
But now imagine that in the **next** compilation, the input has
109-
changed such that `subquery` returns **false**. In this case, `subquery2` would never
108+
changed such that `subquery1` returns **false**. In this case, `subquery2` would never
110109
execute. If try-mark-green were to visit `reads(main_query)` out of order,
111-
however, it might have visited `subquery2` before `subquery1`, and hence executed it.
110+
however, it visit `subquery2` before `subquery1`, and hence execute it.
112111
This can lead to ICEs and other problems in the compiler.
113112

114113
[dep_graph]: https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
@@ -117,8 +116,8 @@ This can lead to ICEs and other problems in the compiler.
117116

118117
In the description basic algorithm, we said that at the end of
119118
compilation we would save the results of all the queries that were
120-
performed. In practice, this can be quite wasteful -- many of those
121-
results are very cheap to recompute, and serializing + deserializing
119+
performed. In practice, this can be quite wasteful many of those
120+
results are very cheap to recompute, and serializing and deserializing
122121
them is not a particular win. In practice, what we would do is to save
123122
**the hashes** of all the subqueries that we performed. Then, in select cases,
124123
we **also** save the results.

0 commit comments

Comments
 (0)