Commit graph

403 commits

Author SHA1 Message Date
Niko Matsakis
e4b822cca4 s/verify_value/mark_value_as_verified/ 2019-07-05 05:59:21 -04:00
Niko Matsakis
87f8517d75 remove max_durability in favor of Durability::MAX 2019-07-05 05:58:23 -04:00
Niko Matsakis
e4cca9b8ff disallow (and remove) dead-code 2019-07-05 05:58:10 -04:00
Niko Matsakis
6252430a91
Update src/input.rs
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-07-05 05:52:36 -04:00
Aleksey Kladov
519bde621c tiny simplification 2019-07-05 10:39:59 +03:00
Aleksey Kladov
1faa9d6016 remove needless clone 2019-07-04 15:20:27 +03:00
Niko Matsakis
5221e95ac4 correct out of date comments and typos 2019-07-04 06:32:08 -04:00
Aleksey Kladov
a7a8309c95 use ptr::eq/hash for readability 2019-07-03 22:24:11 +03:00
Niko Matsakis
e190a291f5
Update src/debug.rs 2019-07-03 06:28:09 -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
880b29a640 move durability to its own module and make part of public API 2019-07-02 07:49:01 -04:00
Niko Matsakis
8b7808c6ae eliminate a built-in notion of constant durability 2019-07-02 07:49:01 -04:00
Niko Matsakis
ccb85989bc rename durability_last_changed_revision to last_changed_revision
The old name was really awkward.
2019-07-02 07:49:01 -04:00
Niko Matsakis
e796af2e7a update comment on durability_last_changed_revision 2019-07-02 07:49:01 -04:00
Niko Matsakis
25ce7ab47b move revisions into a vector indexed by durability 2019-07-02 07:49:01 -04:00
Niko Matsakis
c756d98fbb move revision code to its own module, introduce AtomicRevision
pure refactoring
2019-07-02 07:49:01 -04:00
Niko Matsakis
86dfdd1fda permits things to become *more* durable without a "change"
This will be important if we want to automatically upgrade the
durability of inputs.
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
21a70b6eb0 use a newtype'd IsConstant for better readability
Random bool constants are just so gauche.
2019-07-02 07:49:01 -04:00
Niko Matsakis
e480e08013 simplify slot constant tracking 2019-07-02 07:49:01 -04:00
Niko Matsakis
30714022fd kill the ChangedAt struct
It didn't seem like it was buying us much.
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
Niko Matsakis
ed2bd527e8 use a fixed seed 2019-07-02 06:49:24 -04:00
Niko Matsakis
7bd9e0120f use a proper standard deviation to compare oracle + approx LRU 2019-07-02 06:49:24 -04:00
Niko Matsakis
2750830694 remove outdated comment 2019-07-02 06:49:24 -04:00
Niko Matsakis
e7d704dd8b convert DatabaseSlot to unsafe trait
The unsafe impl now asserts that the `DatabaseSlot` implementor type
is indeed `Send+Sync` if `DB::DatabaseData` is `Send+Sync`. Since our
query keys/values are a part of database-data, this means that `Slot`
must be `Send+Sync` if the key/value are `Send+Sync`. We test this
with a function that will cause compliation to fail if we accidentally
introduce an `Rc<T>` etc.
2019-07-02 06:49:24 -04:00
Niko Matsakis
579e093213 generate a DatabaseData tuple that collects all the key, values 2019-07-02 06:49:24 -04:00
Niko Matsakis
3224c322e8 switch to a NonZeroU64 so that Option<Revision> is one word 2019-07-02 06:49:24 -04:00
Niko Matsakis
4f8c4720d4 change Revision to start from 1 2019-07-02 06:49:24 -04:00
Niko Matsakis
9d550a9343 track dependencies via direct links to slots 2019-07-02 06:49:24 -04:00
Niko Matsakis
50cb001b41 introduce slots to the interner 2019-07-02 06:49:24 -04:00
Niko Matsakis
85848e1bbf complete mysterious comments 2019-07-02 06:49:24 -04:00
Niko Matsakis
11aba6ad2b introduce slots to input storage 2019-07-02 06:49:24 -04:00
Niko Matsakis
03e64254e9 do not store database_key in the slot 2019-07-02 06:49:24 -04:00
Niko Matsakis
7988b5e295 switch to the "random LRU" strategy 2019-07-02 06:49:22 -04:00
Niko Matsakis
d80b3dd879 integrate lru logic into derived table 2019-07-02 06:49:02 -04:00
Niko Matsakis
e9f91f03a5 roll our own lru list
We could use e.g. intrusive-collections but from reading the docs and
surveying the source it wasn't *obvious* to me that it had the right
semantics.
2019-07-02 06:48:59 -04:00
Niko Matsakis
4e5a23b9d7 rewrite derived table to use Slot (LRU not yet supported) 2019-07-02 06:48:32 -04:00
Aleksey Kladov
caa8dcfb06
Update src/runtime.rs
Co-Authored-By: Niko Matsakis <niko@alum.mit.edu>
2019-06-26 13:28:12 +03:00
Aleksey Kladov
6d60798eb8 Replace volatile query type with report_untracked_read fn 2019-06-26 13:10:44 +03:00
Niko Matsakis
efa4696ab7
Merge pull request #171 from matklad/lru
Add LRU to derived storage
2019-06-12 05:43:46 -04:00
Aleksey Kladov
88fed8d6d6 Fix correctness bug when LRU evicted volatile query 2019-06-11 12:59:53 +03:00
Aleksey Kladov
7660277d8e switch to atomic usize 2019-06-10 10:54:17 +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
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
4402338908 Revert "do not expose that RawId is stored in a u32"
This reverts commit 9b106e9279.
2019-03-31 07:34:10 -03:00
Niko Matsakis
d6934ac247 adopt NonZeroU32 2019-03-31 06:49:41 -03:00
Niko Matsakis
9b106e9279 do not expose that RawId is stored in a u32 2019-03-31 06:46:29 -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
0696ed8c3b Removed yet another pair of stray bounds for Send + Sync. This time on keys 2019-03-27 10:44:28 +01:00
Vincent Esche
5aa0455950 Removed remaining stray bounds for Send + Sync that still survived PR #42 2019-03-26 16:21:23 +01:00
Niko Matsakis
c040b0c673 fix gc and volatile tests 2019-03-22 16:24:37 -04:00
Niko Matsakis
c5795a3e5c only GC outdated intern keys 2019-03-22 05:13:07 -04:00
Niko Matsakis
9689d4471b revert take_while changes, which were just .. wrong 2019-03-22 04:58:47 -04:00
Niko Matsakis
c8b30c52e1 nit: change filter to take_while to make clear we stop early
i.e., we never proceed after we find *something* that is dirty.
2019-03-13 05:30:03 -04:00
Niko Matsakis
7d5d01104c document the logic from a FIXME and improve panics 2019-03-13 05:27:14 -04:00
Niko Matsakis
7dcdad88e3 convert to <= when comparing against std::u32::MAX 2019-03-13 05:18:35 -04:00
Niko Matsakis
7ed24f0fa3 use InternIndex also to represent indices from the user 2019-03-13 05:18:35 -04:00
Niko Matsakis
71f250d037 WIP fix DiscardIf::Always, thanks matklad :) 2019-03-12 09:26:46 -04:00
Niko Matsakis
f48515747c create a true inverse key for the lookup path 2019-03-12 08:55:37 -04:00
Niko Matsakis
56ef78109a remove send/sync bounds 2019-02-04 22:10:05 +01: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
Aleksey Kladov
e3c07b010a fast-path no-op gc as well 2019-01-29 19:41:15 +03:00
Aleksey Kladov
f9cae4f2eb just clear the table if we are goining to collect everything 2019-01-29 17:30:43 +03:00
Niko Matsakis
58ba8ac425 rename Query::group_storage method to Query::query_storage 2019-01-28 05:01:53 -05: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
ebd4990bde remove UncheckedMutQueryStorageOps 2019-01-27 17:52:53 -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
9b5c7eeb5e change #[salsa::query_group] attribute to take a struct name 2019-01-25 10:26:39 -05:00
Niko Matsakis
690a118472 consolidate into one HasQueryGroup trait 2019-01-25 09:21:11 -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
1528746267 adopt key, group key, and database key terminology 2019-01-24 06:33:02 -05:00
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