Commit graph

59 commits

Author SHA1 Message Date
Niko Matsakis
1e3c2f22aa Expose the ability to remove the value from an input query, taking ownership of it
Co-authored-by: Tim Robinson <tim.g.robinson@gmail.com>
2022-06-03 05:52:00 -04:00
Niko Matsakis
356392578b new parallel friendly algorithm 2022-01-21 13:58:13 -05: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
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
0630fb1139 track caller to give better line numbers on test errors 2021-10-30 11:38:29 -04: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
67687376ed implement the Storage<DB> change 2020-07-04 14:17:10 +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
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
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
6d60798eb8 Replace volatile query type with report_untracked_read fn 2019-06-26 13:10:44 +03:00
memoryruins
db24e677e3 convert tests to use generated set methods 2019-01-28 00:50:09 -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
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
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
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
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
49cc8abe43 introduce query_mut which you must use to get set methods 2018-11-01 04:53: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
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
Niko Matsakis
120ba00f33 remove a lot of () keys 2018-10-18 21:30:55 -04:00
Niko Matsakis
a0c983403d add some tests about setting with same value 2018-10-11 05:49:05 -04:00
Niko Matsakis
5e381f314b add test where we become constant but do not change value 2018-10-11 04:56:34 -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
efa8b0f307 add some simple tests using is_constant 2018-10-11 04:53:24 -04:00
Niko Matsakis
15faf43071 add some tests for constants (check for invalidation) 2018-10-09 20:49:26 -04: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
c93868c9dc make volatile queries memoize
This ensures consistency of results.
2018-10-09 12:41:56 -04:00
Aleksey Kladov
f14d846146 Re-export runtime
cc #17
2018-10-07 14:08:22 +03:00
Niko Matsakis
8366b3a38b rename query_prototype to query_group 2018-10-05 10:35:50 -04:00
Niko Matsakis
55ec1f51d3 switch to use fn 2018-10-05 10:30:17 -04:00
Niko Matsakis
1b98ecb7a8 change to db.query(Query).set(key, value) 2018-10-05 06:58:51 -04:00
Niko Matsakis
0ee6f3884d make query_prototype also define queries, remove query_definition 2018-10-05 05:55:35 -04:00
Niko Matsakis
cd5622c6de make query method get by default
Use `Query.set(db, key, value)` to set. Not sure about this.
2018-10-05 05:28:51 -04:00
Niko Matsakis
a4fb4b7b13 rename query context to database 2018-10-05 04:54:51 -04:00