Commit graph

451 commits

Author SHA1 Message Date
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
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
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
5fe48246a9 take take take, that's all you do 2021-10-31 04:14:55 -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
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
Niko Matsakis
66b26f07c2 introduce Retry probe result
Instead of sending the result back, just have the waiting threads retry
reading the cache.
2021-10-30 11:27:04 -04:00
Niko Matsakis
eb1e06d61d fix typo that's always bugging me 2021-10-30 11:27:04 -04:00
Niko Matsakis
0298163211 move CycleError to the plumbing module 2021-10-30 11:27:04 -04:00
Niko Matsakis
187bd54fa9 move CycleError to plumbing 2021-10-30 11:27:01 -04:00
Niko Matsakis
42a653ca6f use computed recovery strategy
Rather than checking return value of from `Q::cycle_fallback`, we
now consult the computed recovery strategy to decide whether to
panic or to recover. We can thus assume that we will successfully
recover and don't need to check for `None` results anymore.
2021-10-30 11:19:09 -04:00
Niko Matsakis
bcffa4a836 find cycle recovery strategy for a given cycle 2021-10-30 11:10:07 -04:00
Niko Matsakis
fc826b0689 add cycle_recovery_strategy function on database 2021-10-30 11:09:24 -04:00
Niko Matsakis
e49088644d introduce cycle_recovery_strategy function
Find the cycle recovery strategy for a given DatabaseKey.
2021-10-30 11:09:24 -04:00
Niko Matsakis
853006fccf isolate find_cycle_participants into its own fn 2021-10-30 11:09:24 -04:00
Niko Matsakis
d082270610 introduce CYCLE_STRATEGY constant for queries
This allows us to figure out whether a query can recover
from a cycle (and how) without invoking the `recover`
function.
2021-10-30 11:09:24 -04:00
Niko Matsakis
7b4ee6fc34 improve panic error message 2021-10-30 11:09:08 -04:00
Jonas Schievink
8f0b9b7f82 Fix invalidate and report_synthetic_read 2021-09-03 23:35:15 +02:00
Tim Robinson
fc6806a07c CI runs Clippy 2021-06-17 15:21:51 +01:00