Commit graph

194 commits

Author SHA1 Message Date
Jonas Schievink
458266e1cd Move unwind_if_cancelled to Database 2021-05-25 15:34:57 +02:00
Jonas Schievink
1fb660c33e Use the more common spelling of cancell{ed,ation} 2021-05-25 15:08:23 +02:00
Jonas Schievink
f9cb032568 Fix "frozen" test 2021-05-25 14:55:38 +02:00
Jonas Schievink
223f87bb18 Canonicalize to US spelling of "cancelation" 2021-05-18 15:36:43 +02:00
Jonas Schievink
49a1184bcf Improve Canceled API 2021-05-18 14:41:45 +02:00
Jonas Schievink
197b01fa4b Implement "opinionated cancellation" 2021-05-17 18:59:28 +02:00
Niko Matsakis
fad97eeb6a remove the DB parameter
This had two unexpected consequences, one unfortunate, one "medium":

* All `salsa::Database` must be `'static`. This falls out from
`Q::DynDb` not having access to any lifetimes, but also the defaulting
rules for `dyn QueryGroup` that make it `dyn QueryGroup + 'static`. We
don't really support generic databases anyway yet so this isn't a big
deal, and we can add workarounds later (ideally via GATs).

* It is now statically impossible to invoke `snapshot` from a query,
and so we don't need to test that it panics. This is because the
signature of `snapshot` returns a `Snapshot<Self>` and that is not
accessible to a `dyn QueryGroup` type. Similarly, invoking
`Runtime::snapshot` directly is not possible becaues it is
crate-private. So I removed the test. This seems ok, but eventually I
would like to expose ways for queries to do parallel
execution (matklad and I had talked about a "speculation" primitive
for enabling that).

* This commit is 99% boilerplate I did with search-and-replace. I also
rolled in a few other changes I might have preferred to factor out,
most notably removing the `GetQueryTable` plumbing trait in favor of
free-methods, but it was awkward to factor them out and get all the
generics right (so much simpler in this version).
2020-07-04 14:17:11 +00:00
Niko Matsakis
0e5366df5d move to QueryType.in_db(&db) instead of db.query(QueryType)
This will be more compatible once we move to having queries have an
associated `DynDb` type. It also reads nicely.
2020-07-04 14:17:11 +00:00
Niko Matsakis
12f54d66f4 move query/query-mut to DatabaseQueryExt 2020-07-04 14:17:11 +00:00
Niko Matsakis
d1fe9950c5 simplify salsa_event and make it dyn-safe 2020-07-04 14:17:11 +00:00
Niko Matsakis
67687376ed implement the Storage<DB> change 2020-07-04 14:17:10 +00:00
Niko Matsakis
b3ffaec3b0 remove salsa::requires feature 2020-07-04 14:16:50 +00:00
Niko Matsakis
1b778760ae track and report cycles using DatabaseKeyIndex 2020-07-04 14:16:50 +00:00
Niko Matsakis
8c133e7a4d make synthetic_write require &mut self (breaking change!)
This was an oversight before -- the current type implies that
one introduce a synthetic write (and hence a new revision) from
a `Frozen<DB>`! Not cool.
2019-09-27 05:50:16 -04:00
Niko Matsakis
b9f00726da introduce Database::salsa_runtime_mut method (breaking change!) 2019-09-27 05:49:15 -04:00
Aleksey Kladov
ec5b92ea20 tests and docs for on-demand input pattern 2019-09-20 12:25:12 +03:00
Markus Westerlind
897ee5f3d2 cargo fmt 2019-08-21 10:13:08 +02:00
Markus Westerlind
0e01067d55 feat: Allow queries to avoid panics on cycles
Quickest POC I could create to get some potentially cyclic queries to
not panic and instead return a result I could act on. (gluon's module
importing need to error on cycles).

```
// Causes `db.query()` to actually return `Result<V, CycleError>`
fn query(&self, key: K, key2: K2) -> V;
```

A proper implementation of this would likely return
`Result<V, CycleError<(K, K2)>>` or maybe larger changes are needed.

cc #6
2019-08-16 20:37:54 +02:00
Niko Matsakis
b272cc1321
Merge pull request #180 from nikomatsakis/durability
Durability
2019-08-15 07:01:00 -04:00
Niko Matsakis
ac93c950be make interned keys have durability high 2019-07-02 08:22:25 -04:00
Niko Matsakis
9d474363fc s/next_revision/synthetic_write/
Also write some docs explaining its side-effects.
2019-07-02 07:49:01 -04:00
Niko Matsakis
a0a6bac5af modify public API to set_foo_with_durability 2019-07-02 07:49:01 -04:00
Niko Matsakis
09c9bd9761 adjust public api from is_constant to durability 2019-07-02 07:49:01 -04:00
Niko Matsakis
7bf4f9dc4f silence rng deprecation warning 2019-07-02 07:49:01 -04:00
Niko Matsakis
5bbd500c64 switch internally from IsConstant to Durability 2019-07-02 07:49:01 -04:00
Niko Matsakis
0a5b6b0451 permit constants to be modified
We now track the last revision in which constants were modified. When
we see a constant query result, we record the current revision as
well. Then later we can check if the result is "still" constant. This
lets us cut out a lot of intermediate work.
2019-07-02 07:49:01 -04:00
Aleksey Kladov
89237e85f7 ⬆️ rand 2019-07-02 14:40:43 +03:00
Aleksey Kladov
6d60798eb8 Replace volatile query type with report_untracked_read fn 2019-06-26 13:10:44 +03:00
Aleksey Kladov
88fed8d6d6 Fix correctness bug when LRU evicted volatile query 2019-06-11 12:59:53 +03:00
Aleksey Kladov
0827c88259 use single lock for LRU 2019-06-09 16:47:51 +03:00
Aleksey Kladov
3d89c0d817 Add LRU to derived storage
LRU allows to bound the maximum number of *values* that are present in
the table.
2019-06-07 14:26:21 +03:00
Aleksey Kladov
fcc7058e9c implement strong panic safety
Previosly, panicking query would remove in-progress memos from the
table.

However, we use panic for cancellation, so it's reasonable to **not**
remove the old result after panic. This is also known as string
exception safety guarantee: not only database is in *some* consistent
state after a panic, it is in the same state it was before the panic!
2019-06-01 23:19:15 +03:00
Aleksey Kladov
ccc01cc189 fix test doc comment 2019-05-30 12:32:24 +03:00
Aleksey Kladov
6ea5413ef5 switch requires syntax to an attribute 2019-05-21 18:49:18 +03:00
Aleksey Kladov
940eed92a6 allow private requirements in query groups 2019-05-21 18:04:01 +03:00
Aleksey Kladov
fe295c1b6e Add transparent query type
Transparent queries are not really queries: they are just plain
uncached functions without any backing storage.

Making a query transparent can be useful to figure out if caching it
at all is a win
2019-04-30 23:42:17 +03:00
Niko Matsakis
dbc9d27d16 squash some warnings 2019-04-03 11:01:38 -03:00
Niko Matsakis
74294f71f3 s/RawId/InternId/ 2019-04-03 11:01:20 -03:00
Niko Matsakis
40d0c8d21a
Merge pull request #157 from nikomatsakis/raw-id
adopt raw-id for interned keys
2019-03-31 07:53:38 -03:00
Niko Matsakis
da1b26a52e adopt raw-id 2019-03-30 06:43:16 -03:00
Niko Matsakis
5e84531d7b
Merge pull request #153 from regexident/send
Removed remaining stray bounds for `Send + Sync` that still survived PR #42
2019-03-29 08:24:05 -04:00
Aleksey Kladov
9d6236bc79 make sure interned state is send 2019-03-27 14:33:59 +03:00
Vincent Esche
065d691175 Added test case for !Send + !Sync keys (vs. values) 2019-03-27 10:49:44 +01:00
Vincent Esche
0ba1072c67 Addes test case for !Send + !Sync 2019-03-27 10:35:09 +01:00
Niko Matsakis
5c7e2fee09 s/AtomicU32/AtomicUsize/ in tests 2019-03-25 14:40:32 -04:00
Niko Matsakis
c040b0c673 fix gc and volatile tests 2019-03-22 16:24:37 -04:00
Niko Matsakis
6cf1ffd24a test reverse lookup after we have reused slots and the like 2019-03-22 05:20:00 -04:00
Niko Matsakis
791ec3065c elaborate a bit more on the GC tests 2019-03-22 05:18:32 -04:00
Niko Matsakis
c5795a3e5c only GC outdated intern keys 2019-03-22 05:13:07 -04:00
Niko Matsakis
f48515747c create a true inverse key for the lookup path 2019-03-12 08:55:37 -04:00
Niko Matsakis
1fbd61bf87 adopt InternKey trait 2019-02-04 21:01:58 +01:00
Niko Matsakis
e3f5eb6ee8 implement #[salsa::interned] query storage 2019-02-03 20:45:52 +01:00
Niko Matsakis
1002d7e70a
Merge pull request #138 from matklad/flexible-gc
Make GC API more orthogonal and flexible
2019-01-28 04:51:02 -05:00
memoryruins
db24e677e3 convert tests to use generated set methods 2019-01-28 00:50:09 -05:00
memoryruins
7d12f4f93a remove set_unchecked methods 2019-01-27 17:01:00 -05:00
Aleksey Kladov
9387fd2f4d more orthogonal naming 2019-01-27 17:14:57 +03:00
Aleksey Kladov
d01d6ed511 Make GC API more orthogonal and flexible
Now, the effect of GC is a "product" of three parameters:

* what values are affected (everything/everything except used)
* are we removing values
* are we removing deps

SweepStrategy::default is now a no-op GC.
2019-01-26 21:38:15 +03:00
Niko Matsakis
6f15a440ca make dyn Trait query implementations work 2019-01-25 18:36:23 -05:00
Niko Matsakis
9b5c7eeb5e change #[salsa::query_group] attribute to take a struct name 2019-01-25 10:26:39 -05:00
Niko Matsakis
a468292984 generate set_X and set_constant_X methods for each input
Convert some of the tests to use them
2019-01-25 05:18:26 -05:00
Niko Matsakis
3d1f9dac2d
Merge pull request #122 from matklad/debug
allow to peek at values via debug query interface
2019-01-25 05:13:27 -05:00
Niko Matsakis
a8d9fb2d6b adopt salsa::database attribute macro 2019-01-24 19:02:56 -05:00
Niko Matsakis
c0978fede8 remove the need to list individual queries in database_storage 2019-01-24 05:35:57 -05:00
Aleksey Kladov
a5349b8330 remove debug keys in favor of entries 2019-01-23 14:23:26 +03:00
Niko Matsakis
238be96432 introduce group storage structs to use from database_storage macro
This also detected a bunch of crate visibility mismatches in the
tests.
2019-01-23 05:35:07 -05:00
Niko Matsakis
27af8ca820 add (failing) test that checks that we clear query stack 2019-01-18 05:52:02 -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
61e1d69fb5 preserve both cancellation strategies 2019-01-11 10:13:38 +03:00
Aleksey Kladov
88313c8030 test unwinding-based cancelation 2019-01-10 13:34:20 +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
Niko Matsakis
880681df49 make a test for transitive cancellation 2019-01-04 13:51:10 -05:00
Niko Matsakis
e5043a5644 make sum invoke is_current_revision_canceled deterministically 2019-01-04 13:51:09 -05:00
Niko Matsakis
da3be98295 extend cancellation test 2019-01-04 13:51:07 -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
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
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
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
cf9db9cc7f fix typo 2018-10-30 20:38:41 -04:00
Niko Matsakis
e355300554 use callbacks in parallel test 2018-10-30 20:19:25 -04:00
Aleksey Kladov
f4c00cfe97 Add a stress test 2018-10-30 14:41:56 -04:00
Niko Matsakis
13ae45d441 remove input policies 2018-10-30 12:59:33 -04:00
Niko Matsakis
042f89e7f8 add input policies to permit a wider range of inputs 2018-10-26 19:34:11 -04:00
Aleksey Kladov
f709e64bd5 Add one more cancellation test
closes #66
2018-10-25 17:06:55 +03:00
Niko Matsakis
a8e1e47a59 add simple test for SweepStrategy::discard_values() 2018-10-25 08:41:26 -04:00
Niko Matsakis
c21ea47cfc introduce SweepStrategy 2018-10-25 05:48:37 -04:00
Niko Matsakis
370e46ff6a tests that include non-constants 2018-10-25 05:48:37 -04:00
Niko Matsakis
b9ae3dbc4c test for "shallow constant sweep" 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
c4d93f9733 rename test to give it a unique prefix 2018-10-25 05:47:45 -04:00
Niko Matsakis
ce24850c3d switch assert_log to a better debug library 2018-10-25 05:47:45 -04:00