Commit graph

840 commits

Author SHA1 Message Date
Niko Matsakis
cc2f8870c1 Cleanup edges, panics for diagram 2021-11-04 05:35:55 -04:00
Niko Matsakis
accde0ad70 doc "maybe changed since" and terminology 2021-11-04 05:29:43 -04:00
Niko Matsakis
7d66224319 start expanding the book (wip!) 2021-11-03 10:53:39 -04:00
Niko Matsakis
2f5e1d15d7 add diagram of derived query reads
Created in draw.io, should be editable from there.
2021-11-03 07:49:08 -04:00
Niko Matsakis
072184f486 FetchMaybeChanged.drawio 2021-11-03 04:23:37 -04:00
Niko Matsakis
33d47cc747 throw Cycle value directly
Do not wrap in Cancelled.
2021-11-02 12:45:42 -04:00
Niko Matsakis
ff7f5b60b0 first RFC draft 2021-11-02 07:07:22 -04:00
Niko Matsakis
eb307e4868 rename and incorporate new test 2021-11-02 06:23:48 -04:00
Niko Matsakis
62e2fabab9 on fallback, get deps from all cycle participants
We used to store a changed-at/durability that reflected only
the current frame in a cycle -- but really we are dependent
across the entire cycle, so we now store the max changed-at and
min durability from the entire thing.
2021-11-02 06:18:58 -04:00
Niko Matsakis
7dbacbcf2b rotate the participants in the cycle once
Rotate the participants in the cycle when the cycle is created
rather than doing it "on the fly" each time they are iterated.
2021-11-02 06:13:18 -04:00
Niko Matsakis
1011274c9c repeat test configuration
The default made tests harder to read.
2021-11-02 06:13:18 -04:00
Niko Matsakis
187de0f280 rename fn: query may be in same thread 2021-11-02 06:13:18 -04:00
Niko Matsakis
006848a8cc matklad nikomatsakis 2021-11-02 06:13:18 -04:00
Niko Matsakis
83b2f40ca2 apply cargo fmt 2021-11-02 05:06:26 -04:00
Niko Matsakis
c096f714b5 fix clippy warnings 2021-11-01 13:42:03 -04:00
Niko Matsakis
3f95c0b4a0 panic when recovering from a cycle
It turns out this is necessary, as this test reveals!
If we don't panic, you might encounter further cycles
that aren't supposed to have executed. (Prior to these changes,
this test was panicking from the second cycle.)
2021-11-01 10:10:50 -04:00
Niko Matsakis
1027342468 introduce QueryRevisions and use everywhere
`QueryRevisions` is a shared struct that contains
"everything a query read thus far" -- it is roughly
the old `MemoRevisions` but without `verified_at`.

This change is useful because when a cycle occurs it
allows us to isolate out "inputs thus far" more easily.
2021-11-01 06:10:07 -04:00
Niko Matsakis
891a866653 refactor Memo to just be parameterized over V 2021-10-31 09:47:15 -04:00
Niko Matsakis
75ee3edd2e introduce Cycle type and use in recovery, errors
The Cycle type gives more structured information and ensures
deterministic ordering of participants within any particular
execution.
2021-10-31 07:21:07 -04:00
Niko Matsakis
3caf965533 limit visibility of CycleError 2021-10-31 06:41:05 -04:00
Niko Matsakis
ea6eedd9a3 test cycles with mixed recovery 2021-10-31 06:35:55 -04:00
Niko Matsakis
61599cc81a report unexpected cycles using Cancelled
The `Cancelled` struct now reflects multiple potential reasons
for a query execution to be cancelled, including unexpected cycles.
It also gives information about the participants that lacked
recovery information.
2021-10-31 06:18:50 -04:00
Niko Matsakis
4a1dffe7bc cleanup: move cycle recovery into try_block_on
This is just a refactoring.
2021-10-31 05:39:15 -04:00
Niko Matsakis
f659e1d2dd docs: improve diagram, split gen. code and runtime 2021-10-31 04:30:11 -04:00
Niko Matsakis
5fe48246a9 take take take, that's all you do 2021-10-31 04:14:55 -04:00
Niko Matsakis
d8a792ce60 use RefCell::take 2021-10-31 04:13:42 -04:00
Niko Matsakis
cb00077ebc silence clippy warnings
cargo clippy --fix ftw
2021-10-30 17:20:32 -04:00
Niko Matsakis
a53b1c53f1 put queries on the stack when validating 2021-10-30 11:46:37 -04:00
Niko Matsakis
b0eaa59139 make execute_query take active_query argument 2021-10-30 11:46:37 -04:00
Niko Matsakis
0af2a9fba7 add helper for pushing queries
This permits us to separate pushing on the query stack
from executing the query.
2021-10-30 11:46:30 -04:00
Niko Matsakis
54277d4ad1 remove silly duration parameter 2021-10-30 11:45:18 -04:00
Niko Matsakis
293e103c09 make "maybe changed since" share code with read
It is still *slightly* different from `read`.
This seems to have fixed various bugs.
2021-10-30 11:45:12 -04:00
Niko Matsakis
5adb3c9ab3 add debug methods that carry db 2021-10-30 11:39:50 -04:00
Niko Matsakis
d0c74935c9 break out a helper for executing queries
we're going to use it from maybe_changed_since soon
2021-10-30 11:38:29 -04:00
Niko Matsakis
91ed93a4d4 distinguish no-value from not computed at all
In the case of no-value, we track the revision where
the value was last changed, which will be useful for
maybe-changed-since.
2021-10-30 11:38:29 -04:00
Niko Matsakis
e7a8abc648 distinguish stale vs absent
The goal is to make `probe` usable for both "maybe changed since" and
reading the final value.
2021-10-30 11:38:29 -04:00
Niko Matsakis
0630fb1139 track caller to give better line numbers on test errors 2021-10-30 11:38:29 -04:00
Niko Matsakis
dc5ea932ef WaitResult can just be panicked|completed now 2021-10-30 11:38:27 -04:00
Niko Matsakis
de7ac896bc put cycle participants into an arc
Because it bugs me to clone the vector.

Maybe silly, I admit, since cycle recovery
is not the hot path.

But by that same token, we now spend only 1 word
for a null pointer instead of 4 words for a (usually empty) vector.
2021-10-30 11:37:23 -04:00
Niko Matsakis
5bd2cbcb20 remove unnecessary type argument K 2021-10-30 11:37:21 -04:00
Niko Matsakis
35ddd36b49 move the stack instead of cloning
Currently, when one thread blocks on another, we clone the
stack from that task. This results in a lot of clones, but it also
means that we can't mark all the frames involved in a cycle atomically.
Instead, when we propagate information between threads, we also
propagate the participants of the cycle and so forth.

This branch *moves* the stack into the runtime while a thread
is blocked, and then moves it back out when the thread resumes.
This permits the runtime to mark all the cycle participants at once.
It also avoids cloning.
2021-10-30 11:35:04 -04:00
Niko Matsakis
e83bae717d have runtime coordinate blocking
Instead of creating a future for each edge
in the graph, we now have all dependent queries
block in the runtime and wake up whenever results
are published to see if their results are ready.

We could certainly allocate a CondVar for each dependent
query if we found that spurious wakeups were a problem.
I consider this highly unlikely in practice.
2021-10-30 11:32:56 -04:00
Niko Matsakis
3c094d2932 midpoint: make runtime take wait-result
Thi sis an intermediate step towards having the runtime
coordinate wakeups.
2021-10-30 11:31:18 -04:00
Niko Matsakis
21cb4ef9d6 move WaitResult to runtime
We are going to make it so that the runtime
coordinates delivery of the WaitResults.
2021-10-30 11:31:16 -04:00
Niko Matsakis
f5a15e55c6 rework the dep-graph API to take the lock
This will allow me to add condvar logic to it
2021-10-30 11:30:21 -04:00
Niko Matsakis
213e16f4ee remove explicit Default impl 2021-10-30 11:30:21 -04:00
Niko Matsakis
ba6165726b rename labels to query_dependents 2021-10-30 11:30:21 -04:00
Niko Matsakis
ec38398991 extract the depends_on helper function
Make `add_edge` infallible
2021-10-30 11:30:21 -04:00
Niko Matsakis
e870d02da1 make the dep-graph not generic
Being generic over the keys made code harder to read.
2021-10-30 11:30:21 -04:00
Niko Matsakis
da188fe609 extract DependencyGraph into its own module 2021-10-30 11:30:12 -04:00