Skip to content

Commit 4e0755f

Browse files
jdonszelmannlcnr
andauthored
improve query system documentation (rust-lang#2041)
* improve query system documentation * fix typo messages => message * Update src/queries/incremental-compilation-in-detail.md Co-authored-by: lcnr <[email protected]> --------- Co-authored-by: lcnr <[email protected]>
1 parent 1239ad3 commit 4e0755f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/queries/incremental-compilation-in-detail.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ By using red-green marking we can avoid the devastating cumulative effect of
186186
having false positives during change detection. Whenever a query is executed
187187
in incremental mode, we first check if its already green. If not, we run
188188
`try_mark_green()` on it. If it still isn't green after that, then we actually
189-
invoke the query provider to re-compute the result.
189+
invoke the query provider to re-compute the result. Re-computing the query might
190+
then itself involve recursively invoking more queries, which can mean we come back
191+
to the `try_mark_green()` algorithm for the dependencies recursively.
190192

191193

192194
## The Real World: How Persistence Makes Everything Complicated

src/queries/incremental-compilation.md

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ not a general graph).
2121

2222
[DAG]: https://en.wikipedia.org/wiki/Directed_acyclic_graph
2323

24+
> **NOTE**: You might think of a query as simply the definition of a query.
25+
> A thing that you can invoke, a bit like a function,
26+
> and which either returns a cached result or actually executes the code.
27+
>
28+
> If that's the way you think about queries,
29+
> it's good to know that in the following text, queries will be said to have colours.
30+
> Keep in mind though, that here the word query also refers to a certain invocation of
31+
> the query for a certain input. As you will read later, queries are fingerprinted based
32+
> on their arguments. The result of a query might change when we give it one argument
33+
> and be coloured red, while it stays the same for another argument and is thus green.
34+
>
35+
> In short, the word query is here not just used to mean the definition of a query,
36+
> but also for a specific instance of that query with given arguments.
37+
2438
On the next run of the compiler, then, we can sometimes reuse these
2539
query results to avoid re-executing a query. We do this by assigning
2640
every query a **color**:

src/queries/query-evaluation-model-in-detail.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ Since query providers are regular functions, this would behave much as expected:
174174
Evaluation would get stuck in an infinite recursion. A query like this would not
175175
be very useful either. However, sometimes certain kinds of invalid user input
176176
can result in queries being called in a cyclic way. The query engine includes
177-
a check for cyclic invocations and, because cycles are an irrecoverable error,
178-
will abort execution with a "cycle error" messages that tries to be human
179-
readable.
177+
a check for cyclic invocations of queries with the same input aguments.
178+
And, because cycles are an irrecoverable error, will abort execution with a
179+
"cycle error" message that tries to be human readable.
180180

181181
At some point the compiler had a notion of "cycle recovery", that is, one could
182182
"try" to execute a query and if it ended up causing a cycle, proceed in some

0 commit comments

Comments
 (0)