Commit graph

48 commits

Author SHA1 Message Date
Niko Matsakis
a27befeeba run tests with UPDATE_EXPECT=1 2024-08-20 10:09:49 -04:00
Carl Meyer
56e29b554d
Add test tracing, fix up comments 2024-08-05 08:34:59 -07:00
Niko Matsakis
daaa78056a switch to new database design
Under this design, *all* databases are a
`DatabaseImpl<U>`, where the `U` implements
`UserData` (you can use `()` if there is none).

Code would default to `&dyn salsa::Database` but
if you want to give access to the userdata, you
can define a custom database trait
`MyDatabase: salsa::Databse` so long as you

* annotate `MyDatabase` trait definition of
  impls of `MyDatabase` with `#[salsa::db]`
* implement `MyDatabase` for `DatabaseImpl<U>`
  where `U` is your userdata (this could be a
  blanket impl, if you don't know the precise
  userdata type).

The `tests/common/mod.rs` shows the pattern.
2024-07-28 12:47:50 +00:00
Niko Matsakis
a5395665ce order cycles by debug_name first
We used to sort just by the ingredient index,
but since those are now added dynamically,
that can be fairly unstable in some of the tests.
We now sort by the "debug name" of the ingredient
first, which is more reliably stable.
2024-07-24 10:10:37 +00:00
Niko Matsakis
8a39bf029b wip 2024-07-16 06:04:01 -04:00
Matthijs Brobbel
c7851112a5
Rename salsa-2022 to salsa 2024-06-18 09:40:21 +02:00
Matthijs Brobbel
db75ae00a2
Remove old salsa 2024-06-18 09:25:26 +02:00
andrzej.gluszak
73102b1e8e Fix clippy issues 2022-08-24 18:45:53 +02:00
Bernardo Uriarte
927d905e58 test-env-log has been renamed to test-log 2022-08-22 11:00:47 +02:00
Niko Matsakis
5ebd2211a5 don't recover when not a participant
When a query Q invokes a cycle Q1...Q1 but Q is not a
participant in that cycle, Q should not recover! Test that.
2021-11-12 05:50:06 -05:00
Niko Matsakis
45434cfa93 rework cycle to permit partial recovery (wip)
This is "wip" because it does not yet handle cross-thread recovery
correctly. That is coming in a later commit.
2021-11-11 06:54:32 -05:00
Niko Matsakis
961599aa39 unwind from "block on" for panic/cancellation
We still record the same dependencies (or else the tests fail,
so +1 for test coverage).

This has the immediate advantage that we don't invoke the fallback
function twice for the repeated node in the cycle.

Also, fix a bug where revalidating cycles could lead to a
CycleParticipant error that is not caught (added a test for it).
2021-11-08 08:07:45 -05:00
Niko Matsakis
33d47cc747 throw Cycle value directly
Do not wrap in Cancelled.
2021-11-02 12:45:42 -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
1011274c9c repeat test configuration
The default made tests harder to read.
2021-11-02 06:13:18 -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
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
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
a53b1c53f1 put queries on the stack when validating 2021-10-30 11:46:37 -04:00
Niko Matsakis
7b9c383eb0 improve parallel cycle tests
They now use signals to guarantee we are testing the code paths
we want to be testing.
2021-10-30 11:15:08 -04:00
Niko Matsakis
b4a04531a9 document what we are testing, rename variables 2021-10-30 11:10:10 -04:00
Niko Matsakis
40139abc24 enable debug logging in the cycles tests 2021-10-30 11:09:08 -04:00
Niko Matsakis
b72b251240 add should-panic annotations to cycle tests that fail 2021-10-30 11:09:08 -04:00
Aleksey Kladov
0f3bc72ec0 Add tests for "dynamic" cycles
If I am not in an error, all current tests uses "static" cycles -- a
cycle always present. Let's spice that up by adding conditional cycles:
cycles that appear only for specific impls
2021-10-30 11:09:05 -04:00
Florian Diebold
ae8348c4f1 Add failing test for cycle revalidation 2021-10-30 11:07:40 -04:00
Tim Robinson
fc6806a07c CI runs Clippy 2021-06-17 15:21:51 +01: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
67687376ed implement the Storage<DB> change 2020-07-04 14:17:10 +00:00
Niko Matsakis
b9f00726da introduce Database::salsa_runtime_mut method (breaking change!) 2019-09-27 05:49:15 -04: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
Aleksey Kladov
6d60798eb8 Replace volatile query type with report_untracked_read fn 2019-06-26 13:10:44 +03:00
Niko Matsakis
9b5c7eeb5e change #[salsa::query_group] attribute to take a struct name 2019-01-25 10:26:39 -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
120ba00f33 remove a lot of () keys 2018-10-18 21:30:55 -04:00
Aleksey Kladov
1c349d4229 Switch crate to pub(crate) 2018-10-09 22:34:30 +03: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
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
Niko Matsakis
2ddc8032ee make query_prototype take trait, rename hello_world to compiler 2018-10-01 20:42:41 -04:00
Aleksey Kladov
5b43da0cd2 Add test for cycle detection 2018-10-01 13:48:21 +03:00