Commit graph

319 commits

Author SHA1 Message Date
Niko Matsakis
6451c820b7 rename fns to group_foo 2019-01-24 05:50:13 -05:00
Niko Matsakis
8ad5051a74 make the QueryTable impl totally generic 2019-01-24 05:29:04 -05:00
Niko Matsakis
2924e98f40 add GroupStorage, GroupDescriptor to Query trait 2019-01-24 05:22:31 -05:00
Niko Matsakis
1c415b0c9d rename FromQueryGroupDescriptor and add comments 2019-01-24 05:18:43 -05:00
Niko Matsakis
19d64fd281 add FromQueryGroupDescriptor trait and implement/use it 2019-01-23 11:57:03 -05:00
Niko Matsakis
f3483d1a22 defer for-each-query to the query-group 2019-01-23 10:56:01 -05:00
Niko Matsakis
6cfaf021b0 introduce the GetQueryGroupStorage trait and use it 2019-01-23 08:52:31 -05:00
Aleksey Kladov
a5349b8330 remove debug keys in favor of entries 2019-01-23 14:23:26 +03:00
Aleksey Kladov
a3bbba6187 allow to peek at values via debug query interface 2019-01-22 23:33:45 +03:00
Niko Matsakis
3e81f12dd2
Merge pull request #115 from nikomatsakis/move-unwind-safe-impls
move the RefUnwindSafe impls to shared/local state structs
2019-01-21 11:16:17 -05:00
Niko Matsakis
5f9309f108 remove database_storage macro-rules macro 2019-01-21 10:59:47 -05:00
Cormac Relf
3b15a09b8e replace $crate with salsa in proc macro and make hello_world run 2019-01-21 10:59:12 -05:00
Cormac Relf
38dff4784d add #[doc(hidden)] to __SalsaQueryDescriptor 2019-01-21 20:08:38 +11:00
Niko Matsakis
4ed95c4aae include condition that the storage be unwind safe 2019-01-18 08:53:12 -05:00
Niko Matsakis
4158a4dba5 move the RefUnwindSafe impls to shared/local state structs 2019-01-18 07:12:17 -05:00
Niko Matsakis
f0c5cffd89 add Drop to recover from panic gracefully 2019-01-18 05:52:47 -05:00
Niko Matsakis
21519e6ff7 introduce a ActiveQueryGuard type 2019-01-18 05:49:25 -05:00
Niko Matsakis
15e1366d81 move local-state into its own module 2019-01-18 05:43:39 -05:00
Niko Matsakis
500a60d40d make LocalState encapsulate its state 2019-01-18 05:38:44 -05:00
Niko Matsakis
a2e1d82dee
Merge pull request #110 from matklad/cancelation-docs
document *why* one may want to call is_current_revision_canceled
2019-01-17 05:31:27 -05:00
Niko Matsakis
0f577a2b10 generate an impl of the trait from procedural macro
Instead of generating

```rust
trait Query: GetQueryTable<Foo> {
    fn foo() { .. }
}
```

generate

```rust
trait Query {
}

impl<T> Query for T
where
    T: GetQueryTable<Foo>,
{
    fn foo() { .. }
}
```
2019-01-17 05:04:27 -05:00
Fabian Schuiki
93c30a953d make query_group macro procedural
Switch to a procedural implementation of the `query_group!` macro,
residing in the `components/salsa_macros` subcrate.

Allow the user to override the invoked function via `salsa::invoke(...)`
and the name of the generated query type via `salsa::query_type(...)`.

In all tests, replace the `salsa::query_group! { ... }` invocations with
the new attribute-style `#[salsa::query_group]` macro, and change them
to the new naming scheme for query types (`...Query`).

Update README, examples, and documentation.
2019-01-17 07:24:18 +01:00
Aleksey Kladov
785b73c597 document *why* one may want to call is_current_revision_canceled 2019-01-15 13:45:09 +03:00
Aleksey Kladov
61e1d69fb5 preserve both cancellation strategies 2019-01-11 10:13:38 +03:00
Aleksey Kladov
f07643d232 runtime is unwind-safe iff storage is unwind-safe 2019-01-11 10:04:09 +03:00
Aleksey Kladov
b637e1a9bb mark runtime as UnwindSafe
An alternative would be to mark bit of state as runtime safe, but as
Runtime directly contains a RefCell we need to mark it as a whole
anyway!
2019-01-10 13:34:20 +03:00
Aleksey Kladov
add15d83ea add panic hooks
To implement cancellation via unwinding, one needs to throw `Canceled`
value in `if_current_revision_is_canceled` and `on_propagated_panic`.
2019-01-10 12:15:37 +03:00
Niko Matsakis
b3c7ec9f0d change cancelation mechanism and track "anon" reads when uncanceled 2019-01-04 13:50:50 -05:00
Niko Matsakis
d6990133b4 add debug logs 2019-01-04 08:39:59 -05:00
Niko Matsakis
f5871e4c2f revert transitive report_untracked_read change 2019-01-04 08:39:42 -05:00
Aleksey Kladov
a2198f1f8a prevent untracked queries from moving brackwards in time
If a query observes an untracked read, it gets changed_at equal to the
current revision. When we re-validate the query later, if it doesn't
do an untracked read this time, it gets changed_at equal to the
maximum of the dependencies. Crucially, this new changed_at may
be **older** then the previous value of changed_at. That is, we break
the rule that `changed_at` monotonically increases.

This can lead to missed re-executions down the line (see the added
test).

closes #66
2018-12-30 10:54:34 +03:00
Niko Matsakis
7074e258ba
Merge pull request #98 from matklad/debug
show SharedState in Debug for Runtime
2018-12-28 10:25:16 -05:00
Niko Matsakis
2e4ff9a26e remove use of upgradable reads from derived queries 2018-12-24 10:10:22 -05:00
Aleksey Kladov
52206d5421 show SharedState in Debug for Runtime
This should be useful to debug deadlocks due to bad forking.
2018-12-21 12:12:06 +03:00
Niko Matsakis
3cde493e4e remove the virtual fn call for creating query descriptors
Previously, to "make the connection" between the database type `DB` and
the query type `Q`, we were passing down a fn pointer that would crate
the query descriptor. But now we have this `GetQueryTable` trait -- use
that instead.
2018-12-13 05:51:45 -05:00
Niko Matsakis
1af16d5d7c
Merge pull request #81 from kleimkuhler/issue-24-ensure-parallel-panic-safety
Ensure parallel panic safety
2018-11-04 06:22:28 -05:00
Kevin Leimkuhler
bc60b09fc7 Refactor overwrite_placeholder into PanicGuard 2018-11-01 16:53:08 -07:00
Kevin Leimkuhler
461ab22822 Change uses of fork to snapshot 2018-11-01 11:26:16 -07:00
Kevin Leimkuhler
83482293c6 Use Event API and add docs 2018-11-01 11:26:16 -07:00
Kevin Leimkuhler
5bface5bb9 Ensure parallel panic safety and add test 2018-11-01 11:26:16 -07:00
Aleksey Kladov
229c0b944d make Snapshot Debug 2018-11-01 15:16:57 +03:00
Niko Matsakis
d689d02117 remove outdated note on atomicity; not a concern anymore 2018-11-01 05:03:09 -04:00
Niko Matsakis
341619d20e reorganize to put "how to implement this" at the end 2018-11-01 05:02:33 -04:00
Niko Matsakis
5a88871b9a improve snapshot docs
Using two snapshots from the same thread isn't really very easy to do,
so we don't have to warn about that really (it's really nested use of
snapshots that's a problem, and to do that you have to use thread-locals
or something just to get the snapshot *into* the database -- at that
point, something is really going wrong)).
2018-11-01 05:01:13 -04:00
Niko Matsakis
a8ca57c06d document (and start warning on missing docs) 2018-11-01 04:57:52 -04:00
Niko Matsakis
49cc8abe43 introduce query_mut which you must use to get set methods 2018-11-01 04:53:56 -04:00
Niko Matsakis
e070bf9809 s/Frozen/Snapshot/ 2018-10-31 20:06:06 -04:00
Niko Matsakis
fc2a720ae2 s/fork/snapshot/ 2018-10-31 20:05:31 -04:00
Niko Matsakis
5066726147 panic if you fork from inside a query for now 2018-10-31 16:03:03 -04:00
Niko Matsakis
2a6b8e07f9 remove the query_in_progress field 2018-10-31 15:59:00 -04:00
Niko Matsakis
252132f9b4 remove the start_query function, which is no longer needed 2018-10-31 13:31:29 -04:00
Niko Matsakis
b0171dbc11 remove fork_mut and adopt new strategy
Required simplifying the various tests.
2018-10-31 12:01:36 -04:00
Niko Matsakis
38dc4c31dd introduce fork, which yields a frozen handle 2018-10-31 06:05:03 -04:00
Niko Matsakis
9cac418ac8 rename fork to fork_mut 2018-10-31 06:03:33 -04:00
Niko Matsakis
2e3f8b1a3d name the field runtime_id 2018-10-30 21:00:33 -04:00
Niko Matsakis
59ab0bd7a2 introduce simple callbacks that can be used to build better logging 2018-10-30 20:19:25 -04:00
Niko Matsakis
39dd71ff66 remove use of upgradable_read from input queries 2018-10-30 15:08:09 -04:00
Niko Matsakis
7cfcbd73b8 remove unnecessary upgradable_read 2018-10-30 14:41:24 -04:00
Niko Matsakis
79e24cfa55 fix typo 2018-10-30 14:40:58 -04:00
Niko Matsakis
abeebfedc8 improve the error message here 2018-10-30 14:40:58 -04:00
Niko Matsakis
1c2b4d8d43 be more careful when updating after a dependency check 2018-10-30 14:40:58 -04:00
Niko Matsakis
aea746cb91
Merge pull request #69 from nikomatsakis/input-policies
add input policies to permit a wider range of inputs
2018-10-30 13:37:10 -04:00
Niko Matsakis
6c75c57cd9 fix docs 2018-10-30 13:19:59 -04:00
Niko Matsakis
13ae45d441 remove input policies 2018-10-30 12:59:33 -04:00
Niko Matsakis
b2c282ff6c
Merge pull request #71 from matklad/more-panics
Panic in PanicGuard if it's not explicitly forgotten
2018-10-29 13:15:56 -04:00
Aleksey Kladov
f66f1913b7 reexport revision guard 2018-10-29 17:09:50 +03:00
Aleksey Kladov
0f4d1e8320 Panic in PanicGuard if it's not explicitly forgotten 2018-10-29 15:53:11 +03:00
Niko Matsakis
8a0f57d5c3 storage input has its own section now 2018-10-27 06:44:28 -04:00
Niko Matsakis
e6d7cee501 no need for format! in panic! 2018-10-27 06:44:19 -04:00
Niko Matsakis
042f89e7f8 add input policies to permit a wider range of inputs 2018-10-26 19:34:11 -04:00
Niko Matsakis
c21ea47cfc introduce SweepStrategy 2018-10-25 05:48:37 -04:00
Niko Matsakis
74cecb6ea5 make sweep_all public and document a *bit* better =) 2018-10-25 05:48:37 -04:00
Niko Matsakis
317281528a adjust locking strategy to be more minimal 2018-10-25 05:48:37 -04:00
Niko Matsakis
7f1d1995aa introduce ability to ask a table what keys it has 2018-10-25 05:48:37 -04:00
Niko Matsakis
649b1a6f99 introduce a sweep routine 2018-10-25 05:48:37 -04:00
Niko Matsakis
d429926ddd treat constants more uniformly
We used to ignore constant inputs entirely. We now track them, but if we
find that a value is constant, we discard ITS inputs.  This means that
-- if we track dependencies -- we have an "outer rim" of constant
values.

Also take the opportunity to reshuffle how derived inputs represent
their state.
2018-10-25 05:48:36 -04:00
Niko Matsakis
1ab8d1a64e refactor ChangedAt into a struct
There are really two orthogonal things going on here.
2018-10-25 05:47:45 -04:00
Niko Matsakis
03751d3d5c convert Tracked to a struct variant 2018-10-25 05:47:45 -04:00
Kevin Leimkuhler
7198902ebd Simplify map write to exclusive write access 2018-10-24 11:00:44 -07:00
Kevin Leimkuhler
917ca42f04 Panic safely in a single threaded context 2018-10-23 21:54:14 -07:00
Niko Matsakis
e6f1f6b7fb replace with_frozen_revision with revision_guard 2018-10-19 06:00:15 -04:00
Niko Matsakis
2cf73b45c1 rename freeze_revision to start_query 2018-10-19 06:00:15 -04:00
Niko Matsakis
c327d08343 add a with_frozen_revision method that permits ad-hoc queries 2018-10-19 06:00:15 -04:00
Niko Matsakis
df320c71dd
Merge pull request #58 from kleimkuhler/issue-56-remove-eq-bound
[WIP] Removal of Eq bound on `Q::Val`
2018-10-19 05:20:44 -04:00
Niko Matsakis
2410a2242c extend doc comment 2018-10-18 21:20:46 -04:00
Niko Matsakis
c0d8a08de9 permit provider fns to be variadic as well 2018-10-18 21:15:24 -04:00
Niko Matsakis
ed2cf2333f support variadic queries in the trait definition 2018-10-18 19:24:38 -04:00
Kevin Leimkuhler
7b20806417 Initial removal of Eq bound on Q::Val 2018-10-18 15:29:15 -07:00
Niko Matsakis
089f489df6
Merge pull request #55 from matklad/illigal-state
Refactor out some illegal states
2018-10-17 04:27:08 -04:00
Aleksey Kladov
5abd02097d Refactor out some illegal states
It's impossible to have an `InProgress` state here, so let's ensure
that!
2018-10-16 12:48:01 +03:00
Niko Matsakis
6a61233902
Merge pull request #51 from matklad/plumbing
Hide public impl detail in the plumbing module
2018-10-16 05:29:57 -04:00
Aleksey Kladov
47e87e0bc2 impl fmt::Debug for Runtime 2018-10-16 11:47:40 +03:00
Aleksey Kladov
4401e88fba Hide public impl detail in the plumbing module 2018-10-16 11:24:51 +03:00
Niko Matsakis
5ec9161598 warn about rust_2018_idioms, not deny
We are on beta so we sort of straddle this line.
2018-10-15 16:40:57 -04:00
Niko Matsakis
de934274d1 block on other threads in maybe_changed_since 2018-10-15 11:55:01 -04:00
Niko Matsakis
cf72c98946 extract register_with_in_progress_thread helper 2018-10-15 11:49:14 -04:00
Niko Matsakis
29831a7430 remove ErrorDetected variant from ProbeState 2018-10-15 09:31:25 -04:00
Niko Matsakis
a8fd113636 merge read_probe and probe 2018-10-15 09:30:08 -04:00
Niko Matsakis
be983aacdf extract read_upgrade into a separate helper
And use it from `maybe_changed_since` where it makes sense.
2018-10-15 08:53:52 -04:00
Niko Matsakis
2ba9c97815 rewrite to thread a Vec<Receiver> to signal waiters
This is both more precise and the logic is simpler.
2018-10-15 08:28:55 -04:00
Niko Matsakis
373e1158f3 only acquire a read-lock when verifying inputs
We no longer use a placeholder.
2018-10-15 05:32:24 -04:00
Niko Matsakis
1799e12aa4 more debug! when executing from inputs 2018-10-15 05:25:05 -04:00
Niko Matsakis
04288dadef track whether a query is in progress more accurately 2018-10-15 05:24:36 -04:00
Niko Matsakis
9d60b1e1cd make query-descriptor-set cheaply cloneable 2018-10-14 20:15:27 -04:00
Niko Matsakis
d2c3025009 refactor probe to be more generic 2018-10-14 07:23:38 -04:00
Niko Matsakis
be08029f8c [WIP] introduce blocking/notification 2018-10-14 06:59:43 -04:00
Niko Matsakis
da94299f19 [WIP] restructure to handle blocking (which we do not yet initiate) 2018-10-13 06:28:05 -04:00
Niko Matsakis
975eaf58d7 change InProgress to a struct form 2018-10-13 06:08:29 -04:00
Niko Matsakis
ea0b196a5d [WIP] await_other_guard fn 2018-10-13 06:04:57 -04:00
Niko Matsakis
00c76be635 refactor derived read to only require read lock
The old setup acquired `upgradable_read` even when the value was cached.
At that point you might as well just a mutex.
2018-10-13 05:45:57 -04:00
Niko Matsakis
a0e14e1806 runtime: dependency graph (wip) 2018-10-12 13:41:55 -04:00
Niko Matsakis
ca329ddd10 store the runtime-id in the InProgress indicator 2018-10-12 12:11:49 -04:00
Niko Matsakis
36f72c0b58 give each forked runtime a unique id 2018-10-12 12:11:49 -04:00
Niko Matsakis
e7e9c1bebb rename revision_lock to query_lock and update comments 2018-10-12 12:11:49 -04:00
Niko Matsakis
4f4676df60 remove a bunch of unused imports 2018-10-12 11:21:40 -04:00
Niko Matsakis
be62e8c7a1 add runtime log 2018-10-12 11:21:40 -04:00
Niko Matsakis
890207346f do not hold input write lock while incrementing revision 2018-10-12 05:28:17 -04:00
Niko Matsakis
d11a15aff9 add debugging methods on input::set 2018-10-12 05:27:42 -04:00
Niko Matsakis
f7d6ebe76a introduce a ParallelDatabase trait 2018-10-11 20:22:38 -04:00
Niko Matsakis
c6f78d5f27 have queries freeze the revision 2018-10-11 16:48:20 -04:00
Niko Matsakis
41b36da054 tracking pending increments and add is_current_revision_canceled 2018-10-11 08:37:15 -04:00
Niko Matsakis
4a8b264b7f add a revision lock 2018-10-11 08:18:16 -04:00
Niko Matsakis
a353ffb13c add back implied outlives bounds
Those were reverted on beta.
2018-10-11 05:49:05 -04:00
Niko Matsakis
6778898a34 track when a value *became* constant
Turns out we need this, as demonstrated by the included test =)
2018-10-11 04:53:49 -04:00
Niko Matsakis
16d151e4c8 add debugging APIs -- just is_constant for now 2018-10-11 04:37:29 -04:00
Niko Matsakis
42b88fe7e6 rewrite map to just grab a write lock, and fix some latent bugs 2018-10-09 20:36:29 -04:00
Niko Matsakis
a7317084dc support set_constant in inputs
FIXME: Need test for the `panic!` case etc
2018-10-09 20:36:29 -04:00
Niko Matsakis
032b269113 extract a set_common helper 2018-10-09 20:36:29 -04:00
Niko Matsakis
1afca5d505 add a Constant for ChangedAt 2018-10-09 20:36:29 -04:00
Niko Matsakis
3ffd166f2c check if input has changed before incrementing revision
WIP -- needs test
2018-10-09 20:36:29 -04:00
Niko Matsakis
6a0ed30d73 rename MutQueryStorageOps to InputQueryStorageOps 2018-10-09 20:36:29 -04:00
Niko Matsakis
a45d482a97
more descriptive assertion failure for overflow 2018-10-09 18:00:27 -04:00
Aleksey Kladov
e42c68913e check revision for overflow 2018-10-10 00:48:19 +03:00
Aleksey Kladov
74486afdec elide some lifetimes 2018-10-10 00:44:26 +03:00
Aleksey Kladov
f28e8c1be5 disable in-band lifetimes 2018-10-09 22:39:03 +03:00
Aleksey Kladov
c3fb7a1f24 disable nll 2018-10-09 22:37:55 +03:00
Aleksey Kladov
69b9dff557 Use AtomicUsize instead of AtomicU64 2018-10-09 22:37:38 +03:00
Aleksey Kladov
1c349d4229 Switch crate to pub(crate) 2018-10-09 22:34:30 +03:00
Niko Matsakis
3b5f16cbcb
Merge pull request #43 from nikomatsakis/derived-storage
Combine memoized and volatile to make "derived storage"
2018-10-09 15:19:14 -04:00
Niko Matsakis
0dd96865c7 refactor to unwrap less 2018-10-09 15:11:57 -04:00
Niko Matsakis
6658a47a36 rename is_volatile to should_track_inputs 2018-10-09 13:28:33 -04:00
Niko Matsakis
c93868c9dc make volatile queries memoize
This ensures consistency of results.
2018-10-09 12:41:56 -04:00
Niko Matsakis
7c65d07ea6 rename from WeakMemoizedStorage to DerivedStorage 2018-10-09 12:15:33 -04:00
Niko Matsakis
5ad0049b9f merge volatile and memoized queries 2018-10-09 12:14:09 -04:00
Niko Matsakis
2d6e454638 add the idea of "untracked reads" and use it to optimize volatile
Now we won't be tracking the inputs to a volatile query, since we don't
care about them anyway.
2018-10-09 11:04:25 -04:00
Niko Matsakis
1e6bfc7fdd introduce a callback into execute_query_implementation 2018-10-09 10:26:33 -04:00
Niko Matsakis
30236cc110 introduce a new helper, verify_inputs 2018-10-09 09:27:59 -04:00
Niko Matsakis
121821117d
Merge pull request #36 from matklad/weak-memoized
Merge Memoized and Dependency storages
2018-10-09 08:53:57 -04:00
Niko Matsakis
296d33aae7 factor out ChangedAt to record when something changed 2018-10-09 08:53:13 -04:00
Niko Matsakis
4efbd411fa check with old_memo.value.is_some() before revalidating inputs 2018-10-09 08:40:53 -04:00