Commit graph

483 commits

Author SHA1 Message Date
XFFXFF
f7519acb13 add a test for specify
`specify` does not work if the key is a `salsa::interned`
2022-08-27 07:51:35 +08:00
XFFXFF
dbe8561721 add some docs for specify 2022-08-27 06:22:04 +08:00
Bernardo Uriarte
b14d12ada9 avoid warnings in generated code 2022-08-26 18:51:51 +02:00
bors[bot]
6ee0889948
Merge #383
383: Have users of `SalsaStruct` specify allowed options r=XFFXFF a=DropDemBits

This allows adding new options exclusively to `tracked`, `input`, `interned`, or any combination of them, without having to add support code to `SalsaStruct`.

The motivating example is #337, where `input` needs to accept a new `singleton` option, but `tracked` and `interned` should reject it.

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2022-08-25 23:39:01 +00:00
DropDemBits
62f0ceb665 Run cargo fmt 2022-08-25 13:19:57 -04:00
bors[bot]
5c63715a95
Merge #381
381: fix typos r=nikomatsakis a=Aadamandersson



Co-authored-by: Adam Andersson <adam.m.andersson@gmail.com>
2022-08-25 10:34:44 +00:00
bors[bot]
63fb4ad24c
Merge #376 #379
376: add `synthetic_write` r=nikomatsakis a=XFFXFF

fixes #364 

add `synthetic_write` and use it in test `lru_keeps_dependency_info`, the test will now be broken. We can use `lru_keeps_dependency_info` as a test for https://github.com/salsa-rs/salsa/issues/365, which already has a pr https://github.com/salsa-rs/salsa/pull/371.

379: Update test.yml r=nikomatsakis a=agluszak

- Add names to steps
- No need to run clippy AND check (https://stackoverflow.com/questions/57449356/is-cargo-clippy-a-superset-of-cargo-check)
- Run clippy on all targets with all features
- Fix issues reported by clippy

Co-authored-by: XFFXFF <1247714429@qq.com>
Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
Co-authored-by: andrzej.gluszak <andrzej.gluszak@mpi-sp.org>
2022-08-25 10:30:34 +00:00
DropDemBits
5927ae23a3 Have users of SalsaStruct specify allowed options 2022-08-25 01:48:34 -04:00
XFFXFF
266505d58e remove synthetic_write from Runtime 2022-08-25 13:46:58 +08:00
XFFXFF
f899551962 fix unused import 2022-08-25 06:43:47 +08:00
XFFXFF
8e754ec0d7 add report_untracked_read to salsa::Database 2022-08-25 06:30:27 +08:00
XFFXFF
e86252d051 add synthetic_write to salsa::Database 2022-08-25 06:13:12 +08:00
XFFXFF
2dc5a6c796 remove salsa_runtime 2022-08-25 06:01:23 +08:00
Adam Andersson
18507f2ff7 fix some typos 2022-08-24 21:12:58 +02:00
andrzej.gluszak
73102b1e8e Fix clippy issues 2022-08-24 18:45:53 +02:00
XFFXFF
0e0626abfa writes with jars_mut 2022-08-24 20:17:13 +08:00
XFFXFF
6776919f39 give salsa_runtime a default implementation 2022-08-24 20:11:48 +08:00
XFFXFF
f5b0ff59d3 add runtime_mut and synthetic_write to HasJarsDyn 2022-08-24 20:01:00 +08:00
XFFXFF
340e2d521d add synthetic write 2022-08-24 19:00:21 +08:00
bors[bot]
5ce4662b81
Merge #371
371: Ported LRU improvements from old salsa to salsa 2022 r=nikomatsakis a=OLUWAMUYIWA

## What?
In handling evictions from the LRU, I replaced the `delete_memo`  with `evict` in the while keeping the `delete_memo` intact. 

## How?
This mechanism was already implemented in old `salsa `. I only had to port it.

Fixes: #365

Co-authored-by: OLUWAMUYIWA <onigbindemy@gmail.com>
Co-authored-by: Onigbinde Oluwamuyiwa Elijah <onigbindemy@gmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-24 10:47:28 +00:00
Niko Matsakis
282f45e011 run cargo fmt 2022-08-24 06:46:03 -04:00
Andrzej Głuszak
8e27ecd098 Fix formatting 2022-08-24 00:10:07 +02:00
Andrzej Głuszak
fdc8018234 Cleanup 2022-08-23 23:38:19 +02:00
Andrzej Głuszak
43cd95fe47 Derive DebugWithDb 2022-08-23 23:26:07 +02:00
Onigbinde Oluwamuyiwa Elijah
4b2c42e3c4
Merge branch 'salsa-rs:master' into lru_port 2022-08-22 20:53:04 +01:00
bors[bot]
d3f0077d21
Merge #369
369: Try to fix issue#340 r=XFFXFF a=zjp-CN

(WIP) 

Follow the instructions from https://github.com/salsa-rs/salsa/issues/340#issuecomment-1210153085.

Still not sure what to do with `fmt_index`...

Fix #340

Co-authored-by: zjp <jiping_zhou@foxmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-22 13:42:18 +00:00
zjp
863ec4ac7f fix(debug_name): impl for InternedIngredient 2022-08-22 21:17:48 +08:00
zjp
4966acbc64 feat(literal): a helper to convert Ident to Literal 2022-08-22 20:22:57 +08:00
Charles Lew
7267452ff1 Implement Setter API 2022-08-22 19:22:47 +08:00
Charles Lew
66b5d45995 Fix local doctest failure. 2022-08-22 19:22:37 +08:00
Niko Matsakis
bf00d4217f apply cargo fmt 2022-08-22 06:21:23 -04:00
Bernardo Uriarte
6dc4eb417b update dashmap and hashlink 2022-08-22 11:00:47 +02:00
Bernardo Uriarte
cbbd05f5d5 update heck 2022-08-22 10:51:34 +02:00
Bernardo Uriarte
78b066cff0 unify parking_lot version 2022-08-22 10:48:21 +02:00
zjp
44e9c63974 feat(fmt_index): impl for DependencyIndex 2022-08-22 11:22:47 +08:00
zjp
f69d80b2c5 ix(fmt_index): impl for TrackedStructIngredient 2022-08-22 10:43:41 +08:00
zjp
b76ac29a09 fix(fmt_index): impl for InputFieldIngredient 2022-08-22 10:33:39 +08:00
zjp
78d7894266 fix(fmt_index): impl for InternedIngredient 2022-08-22 10:14:07 +08:00
zjp
af747c1aca fix(fmt_index): impl for accumulator 2022-08-22 10:04:47 +08:00
zjp
67fd9792f0 fix(fmt_index): implement with the helper function 2022-08-22 10:03:03 +08:00
bors[bot]
3d727f60e2
Merge #363
363: Add method to change LRU capacity at runtime r=nikomatsakis a=XFFXFF

closes #355 

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-22 01:08:27 +00:00
zjp
9f9b46f5e0 revert fmt 2022-08-22 08:36:13 +08:00
OLUWAMUYIWA
ebcb3d62f6 Ported LRU improvements from old salsa to salsa 2022 2022-08-22 01:34:20 +01:00
zjp
525a9fec4c fix(fmt_index): proc macro expansion 2022-08-22 01:00:16 +08:00
zjp
0d7066c554 fix(clippy): follow the advice 2022-08-22 00:57:09 +08:00
zjp
70b0340b81 feat(fmt_index): added in Ingredient trait 2022-08-21 23:55:29 +08:00
zjp
c84f88d23a fmt 2022-08-21 23:47:27 +08:00
bors[bot]
8dfc578edc
Merge #360
360: Permit renaming constructors, getters and setters r=nikomatsakis a=MihailMihov

The goal is to add an option `constructor_name` to `#[salsa::input]`, `#[salsa::interned]` and `#[salsa::tracked]` that allows changing the name of the generated constructor. After that add attributes `get` and `set` to the fields which allow overriding the names of the getters and setters. In the end the following snippet should compile and work:
```rust
#[salsa::interned(constructor = from_string)]
struct MyInterned {
    #[get(text)] #[set(set_text)] #[return_ref]
    field: String,
}

impl MyInterned {
    pub fn new(db: &dyn Db, s: impl Display) -> MyInterned {
        MyInterned::from_string(db, s.to_string())
    }

    pub fn field(self, db: &dyn Db) -> &str {
        self.text(db)
    }

    pub fn set_field(self, db: &mut dyn Db, id: String) {
        self.set_text(&mut db, id)
    }
}
```

resolves #332 

Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
2022-08-21 10:37:21 +00:00
XFFXFF
04b70f54e3 lru can be changed at runtime 2022-08-21 10:02:45 +08:00
Mihail Mihov
958b063a60 Update input, interned and tracked structs to use specified getter and setter names 2022-08-21 01:52:54 +03:00
Mihail Mihov
eb4f97f533 Add get and set to FIELD_OPTION_ATTRIBUTES 2022-08-21 01:22:18 +03:00
Mihail Mihov
2970c16e77 Respect constructor_name option input, interned and tracked structs 2022-08-21 01:19:12 +03:00
Mihail Mihov
6cb1cb0a47 Add constructor_name option to Options 2022-08-21 01:16:45 +03:00
bors[bot]
5f3e0ec6f5
Merge #353
353: start documenting plumbing r=nikomatsakis a=nikomatsakis

Feedback desired! I am trying to document an overview of the new salsa 2022 plumbing. I'd love for folks to [read these docs and tell me if they make sense](https://deploy-preview-353--salsa-rs.netlify.app/plumbing.html).

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-18 23:43:44 +00:00
Niko Matsakis
06e0a04cb3 explain more about rev counter, include snippets 2022-08-18 19:37:59 -04:00
Niko Matsakis
1c9c7280b7 add from impls for u32/usize 2022-08-18 16:36:05 -04:00
bors[bot]
5aebeeb9e5
Merge #356
356: make Id::from_u32 public r=nikomatsakis a=nikomatsakis

I made it private 'just because', but it turns out that dada uses it, and it seems reasonable.

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-18 10:56:53 +00:00
Niko Matsakis
bc01b9b0d1 make Id::from_u32 public
I made it private, but it turns out that dada uses it,
and it seems reasnable.
2022-08-18 06:48:57 -04:00
bors[bot]
eca8bad6e9
Merge #352
352: Add options to tracked funcitons for lru capacity  r=nikomatsakis a=XFFXFF

fixes #344 

Now we can write something like the following to set the lru capacity of tracked functions  
```rust
#[salsa::tracked(lru=32)]
fn my_tracked_fn(db: &dyn crate::Db, ...) { }
```

some details:  
* lru should not be combined with specify. We will report an error if people do #[salsa::tracked(lru = 32, specify)]
* set 0 as default capacity to disable LRU (Because I think doing this would make the code simpler when implementing `create_ingredients` of tracked functions).
* old salsa support to change lru capacity at runtime, [as noted here](https://salsa-rs.github.io/salsa/rfcs/RFC0004-LRU.html?highlight=change#reference-guide), but we do not support this now

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-18 10:37:38 +00:00
Niko Matsakis
b6aec13b20 explain databases, runtimes, etc 2022-08-18 05:37:22 -04:00
Niko Matsakis
a1a8533cef define how routes are created 2022-08-18 05:15:12 -04:00
XFFXFF
fc4d531d76 refactor and cargo fmt 2022-08-18 08:07:13 +08:00
XFFXFF
53785f1355 lru and specify can not be used together 2022-08-17 18:54:55 +08:00
XFFXFF
341fc80726 port more tests about lru 2022-08-17 18:54:55 +08:00
XFFXFF
d080e349ef make lru option work 2022-08-17 18:54:17 +08:00
Niko Matsakis
9df075b63c reset accumulators on new revisions, etc
Accumulators don't currently work across revisions
due to a few bugs. This commit adds 2 tests to show
the problems and reworks the implementation strategy.

We keep track of when the values in an accumulator were pushed
and reset the vector to empty when the push occurs in a new
revision.

We also ignore stale values from old revisions
(but update the revision when it is marked as validated).

Finally, we treat an accumulator as an untracked read,
which is quite conservative but correct. To get better
reuse, we would need to (a) somehow determine when different
values were pushed, e.g. by hashing or tracked the old values;
and (b) have some `DatabaseKeyIndex` we can use to identify
"the values pushed by this query".

Both of these would add overhead to accumulators and I didn'τ
feel like doing it, particularly since the main use case for
them is communicating errors and things which are not typically
used from within queries.
2022-08-17 06:47:11 -04:00
Niko Matsakis
186c915b21 make outputs use DependencyIndex
It turns out that we have some outputs (accumulators) for which
it only makes sense to have a `DependencyIndex` (they don't have
individual keys to identify).
2022-08-17 04:43:25 -04:00
XFFXFF
2d59df39af parse the lru option 2022-08-17 07:22:45 +08:00
Niko Matsakis
f7f1bb9024 add reset for new revision for input fields 2022-08-16 17:58:00 -04:00
Niko Matsakis
7b99365620 add salsa_struct_deleted for input fields 2022-08-16 17:57:41 -04:00
Niko Matsakis
689751b243 wire up salsa struct seletion, test it
We now delete entities and data associated with them!
Neat!
2022-08-16 17:55:32 -04:00
Niko Matsakis
66ffae1bb9 generalize push to always have a &mut route
We also track whether reset is required at the ingredient level.
For tracked struct fields, we were not using `push_mut`,
and I think that was an oversight.

The plan is to do a "dependent ingredient" interlinking pass
once the database is constructed.
2022-08-16 17:55:32 -04:00
Niko Matsakis
60cdce22e9 track "dependent functions" 2022-08-16 17:55:32 -04:00
Mihail Mihov
07dd72470e Rename compare_and_swap to mutate_in_place 2022-08-14 20:24:57 +03:00
Mihail Mihov
11cedfba4f Update methods in InputFieldIngredient 2022-08-13 18:19:37 +03:00
Mihail Mihov
83474bbc53 Fix maybe_changed_after's logic 2022-08-13 13:04:19 +03:00
Mihail Mihov
5fe3c08cb7 Pass the runtime to InputFieldIngredient's fetch 2022-08-13 13:04:19 +03:00
Mihail Mihov
064f26db8f Change QueryInputs to QueryEdges 2022-08-13 13:04:19 +03:00
Mihail Mihov
8e54a9bb3e Report reads in InputFieldIngredient's fetch method. 2022-08-13 13:04:19 +03:00
Mihail Mihov
9b7f7fd4ed Add comments describing InputFieldIngredient
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-13 13:04:19 +03:00
Mihail Mihov
11b23c942b Return old value in input setter methods 2022-08-13 13:04:19 +03:00
Mihail Mihov
ec141aceba Replace inputs' FunctionIngredients with InputFieldIngredients 2022-08-13 13:04:19 +03:00
Mihail Mihov
da43bd2ba6 Add InputFieldIngredient 2022-08-13 13:04:19 +03:00
Niko Matsakis
d80d5308f1 fix annoying formatting problem 2022-08-13 01:28:01 -04:00
Niko Matsakis
b8643a5f70 distinguish fields from other specified values
And make `QueryOrigin` finer grained while we are at it.
2022-08-13 01:21:45 -04:00
Niko Matsakis
e2763aba88 change approach: eagerly verify, don't remove
This approach is more compatible with our overall "pull" result,
and it also means we can get more re-use.
2022-08-13 01:21:45 -04:00
Niko Matsakis
2652f66fc9 messy commit: refactor + add mark_validated_output
I realized I can do this better:

* require that outputs are DatabaseKeyIndex, fewer unwraps,
  more clearly justified
* when we validate result of tracked fn, also validate its outputs
  (this is incompletely implemented, would ideally be separated
  into its own commit, but I'm short for time)

The last step will allow us to keep the memoized results for
assigned values and means we don't have to eagerly clear them.
If we see an "assigned value" that is not verified in the current
revision, it can simply be considered dirty.

We can still delete them when entities are deleted, but they're
less special.
2022-08-13 01:21:45 -04:00
Niko Matsakis
37e7eeb3fd delete stale output values
This fixes the behavior of `specify_tracked_fn_in_rev_1_but_not_2`,
mostly, though I realize now that it is suboptimal.
2022-08-13 01:21:45 -04:00
Niko Matsakis
a3a0f030f6 track the query that assigned the value
We will use this just for asserts, but it seems useful.
2022-08-13 01:21:45 -04:00
Niko Matsakis
af9de5686d delete some dead code, squash wanings 2022-08-13 01:21:45 -04:00
Niko Matsakis
aa88884b51 move "untracked" into the Origin enum
It's a bit of a stretch for the name, but I think the code is cleaner.
2022-08-13 01:21:45 -04:00
Niko Matsakis
0e96d4c1e7 replace edges with origin
We now track whether the value was ASSIGNED or DERIVED.
2022-08-13 01:21:45 -04:00
Niko Matsakis
a58bc82883 create remove_stale_output method on ingredients
but we are not doing anything in it, yet
2022-08-13 01:21:45 -04:00
Niko Matsakis
8accccdbce diff outputs when replacing a memoized value
We don't do anything with this info right now besides log it,
but the logs show we are reporting it at the right times
in the `specify_tracked_fn_in_rev_1_but_not_2` test
(also fix an oversight in the test where it was creating a new input
each time).
2022-08-13 01:21:45 -04:00
Niko Matsakis
c0ac7447c9 track both inputs/outputs for each query
Rename QueryInputs to QueryEdges.
Modify its fields to track both inputs and outputs.
The size of the struct doesn't actually change,
as the separator comes out of padding.
2022-08-13 01:21:45 -04:00
Niko Matsakis
604c182d7b record when specify is called by a user
Pre-declared fields do not need to be recorded,
as they are always specified.
2022-08-13 01:21:45 -04:00
Niko Matsakis
6ad632a747 generalize list of "entities created" to "outputs"
We will record each thing that gets *output* by the query.
We use a btree-set so that we can get a sorted list.
That will allow us to easily compare what is output between revisions.
We will use that to clear stale values.
2022-08-13 01:21:45 -04:00
Niko Matsakis
97e280ddd2 track outputs for the active record 2022-08-13 01:21:45 -04:00
Niko Matsakis
15ec60613c Revert "track outputs for the active record"
This reverts commit de2fb22a1c.
2022-08-12 14:28:30 -04:00
Niko Matsakis
8fc38fed48 Revert "generalize list of "entities created" to "outputs""
This reverts commit cbe7d371c9.
2022-08-12 14:28:28 -04:00
Niko Matsakis
5046ba1e6d Revert "record when specify is called by a user"
This reverts commit 787480ffab.
2022-08-12 14:28:27 -04:00
Niko Matsakis
cb0b53caa7 Revert "track both inputs/outputs for each query"
This reverts commit 49ccac5d3d.
2022-08-12 14:28:26 -04:00
Niko Matsakis
afefcdf335 Revert "diff outputs when replacing a memoized value"
This reverts commit 1e3272bc61.
2022-08-12 14:28:25 -04:00
Niko Matsakis
eabb55632e Revert "create remove_stale_output method on ingredients"
This reverts commit 8b7324dca8.
2022-08-12 14:28:20 -04:00
Niko Matsakis
8b7324dca8 create remove_stale_output method on ingredients
but we are not doing anything in it, yet
2022-08-11 12:15:17 -04:00
Niko Matsakis
1e3272bc61 diff outputs when replacing a memoized value
We don't do anything with this info right now besides log it,
but you can see that we are reporting it at the right times
in the `specify_tracked_fn_in_rev_1_but_not_2` test
(also fix an oversight in the test where it was creating a new input
each time).
2022-08-11 00:56:15 -04:00
Niko Matsakis
49ccac5d3d track both inputs/outputs for each query
Rename QueryInputs to QueryEdges and modify its fields
to track both inputs and outputs. The size of the struct
doesn't actually change, the separator comes out of padding.
2022-08-11 00:28:34 -04:00
Niko Matsakis
787480ffab record when specify is called by a user
We don't need to record it for pre-declared fields,
as they are always specified.
2022-08-10 03:55:04 -04:00
Niko Matsakis
cbe7d371c9 generalize list of "entities created" to "outputs"
We will record each thing that gets *output* by the query.
Use a btree-set so that we can get a sorted list.
That will allow us to easily compare what is output between revisions.
We will use that to clear stale values.
2022-08-10 03:54:04 -04:00
Niko Matsakis
de2fb22a1c track outputs for the active record 2022-08-10 03:46:27 -04:00
Niko Matsakis
d72803c027 don't mark specified values as volatile
This is what we want, but it's not a complete fix.
It does make these tests work, though!
Good enough to commit.
2022-08-10 00:42:32 -04:00
Niko Matsakis
eeb47a065c add a comment to TrackedStructInDb trait 2022-08-10 00:42:32 -04:00
Niko Matsakis
85d88b8df0 give each function a SalsaStruct assoc type 2022-08-10 00:42:32 -04:00
Niko Matsakis
940ed006cf add SalsaStructInDb impls for inputs, interned
Now all types have them.
2022-08-10 00:42:32 -04:00
Niko Matsakis
25e085fbdc add a SalsaStructInDb trait
Not currently used anywhere,
but will be implemented by all salsa structs.
2022-08-10 00:42:32 -04:00
Niko Matsakis
fc5e05fae0 introduce newtype wrappers for each salsa struct
This way they have separate namespaces for their inherent methods.
2022-08-10 00:42:32 -04:00
Niko Matsakis
4400c1b66a make constructing an Id private to salsa
This way we know that all Id instances came from salsa.

Not sure if that matters, but why not?
2022-08-10 00:42:32 -04:00
Niko Matsakis
ac837e2cdc rename set method to specify
That's the method name we use when exposing this to users.
2022-08-10 00:42:32 -04:00
Niko Matsakis
9229b1a23a rename Ingredients to Routes
The old name makes it sound like it contains the
actual ingredients, but really it just contains
the routes we use to find them at runtime.
2022-08-10 00:42:32 -04:00
Niko Matsakis
00d95436e0 more comments 2022-08-10 00:42:32 -04:00
Niko Matsakis
2547823a5f do not allow dead code anymore 2022-08-10 00:42:32 -04:00
Niko Matsakis
f513f46380 add comments, remove dead-code lints 2022-08-10 00:42:32 -04:00
Niko Matsakis
323e677182 enable logging of salsa events by default
and add logging to tests
2022-08-10 00:42:27 -04:00
Niko Matsakis
395df47016 use DebugWithDb trait for the database key index 2022-08-10 00:42:05 -04:00
XFFXFF
9fb5f7a366 add some comments 2022-08-09 08:43:44 +08:00
XFFXFF
045f5186b3 modify tracked_fn macro to use it 2022-08-08 08:57:29 +08:00
XFFXFF
0f907dd3cd add recovery_fn option 2022-08-08 07:32:39 +08:00
Brian Anderson
7e72c0c3df Fix storage examples 2022-08-05 12:17:22 -06:00
Niko Matsakis
fa2d24a0be squash (some) warnings 2022-08-05 14:32:12 -04:00
Niko Matsakis
974725a27d re-export from salsa_2022_macros
d'oh, why didn't this fail CI?
2022-08-05 14:26:13 -04:00
Niko Matsakis
66f1f1c50c rename salsa-entity to salsa-2022 2022-08-05 13:20:14 -04:00
Niko Matsakis
4f234cfbb9 remove component and replace with specify option
You can now do `#[salsa::tracked(specify)]` and you will
get a method `some_fn::specify(...)` that can be used to
specify the value.
2022-08-05 02:51:13 -04:00
Niko Matsakis
1f1950c145 refactor error reporting, detect too few argments 2022-08-05 01:24:07 -04:00
Niko Matsakis
627eddd428 add a test for tracked functions 2022-08-05 00:39:00 -04:00
Niko Matsakis
b4053ad76b rename references to memoized to tracked 2022-08-04 01:42:42 -04:00
Niko Matsakis
91a18114bc s/memoized/tracked-fn/ 2022-08-04 01:41:04 -04:00
Niko Matsakis
8f2f664e96 rename impl stuff from entity to tracked struct 2022-08-03 13:42:33 -04:00
Niko Matsakis
a96cb03a05 remove #[salsa::entity], and #[salsa::tracked] 2022-08-03 09:09:22 -04:00
Niko Matsakis
8ff4f5069e rename EntityLike to SalsaStruct 2022-08-03 08:53:27 -04:00
Niko Matsakis
e331f7102d mark some unused variables 2022-08-03 08:51:14 -04:00
Niko Matsakis
3a55d3072b remove DataItem now that we don't support enums
simpler.
2022-08-03 03:50:46 -04:00
Niko Matsakis
0880be0b79 remove support for interned enums
It's nicer to just define a struct with a data field.
2022-08-03 03:43:39 -04:00
Niko Matsakis
7e3e77d611 fix various small bugs in #[salsa::input] 2022-08-03 00:41:22 -04:00
Niko Matsakis
f0156cca36 rename all_entity_fields to all_field_names 2022-08-03 00:32:27 -04:00
Niko Matsakis
783981dc16 add salsa::input items 2022-08-03 00:31:50 -04:00
Niko Matsakis
1c882bb598 fix missing format! calls in entity_like.rs 2022-08-03 00:31:26 -04:00
Niko Matsakis
196baab60d add InputIngredient
They are a very simple variant on entities
2022-08-03 00:30:52 -04:00
Niko Matsakis
d134e0a54b comment the fields on an interned ingredient 2022-08-03 00:05:37 -04:00
Niko Matsakis
3559ac2b21 remove trailing whitespace 2022-08-02 15:05:28 -04:00
Niko Matsakis
548beade54 extract configuration struct/impl code from entity
`#[salsa::input]` structs will need similar code
2022-08-02 10:56:27 -04:00
Niko Matsakis
f2649ee503 extract helper functions for validation 2022-08-02 14:22:45 +03:00
Niko Matsakis
d0b7046245 quick fix for components w/ optional jar
We need tests!
2022-08-02 07:28:13 +03:00
Niko Matsakis
e3769b5c31 remove trailing whitespace
this seems to be a rustfmt bug?
2022-08-01 13:54:21 +03:00
Niko Matsakis
985650523e entity-based salsa preview 2022-08-01 09:24:49 +03:00
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
bors[bot]
0f9971ad94
Merge #296
296: Slot no more: overhauled internal algorithm r=nikomatsakis a=nikomatsakis

This is the overhauled implementation that avoids slots, is more parallel friendly, and paves the way to fixed point and more expressive cycle handling.

We just spent 90 minutes going over it. [Some rough notes are available here,](https://hackmd.io/6x9f6mavTRS2imfG96tP5A) and a video will be posted soon.

You may find the [flowgraph useful](https://raw.githubusercontent.com/nikomatsakis/salsa/slot-no-more/book/src/derived-query-read.drawio.svg).



Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-02-07 20:30:07 +00:00
Maxwell Elliot Heiber
a1be30bc13 Make storage fields of #nameGroupStorage private
This change resolves a fixme that referenced #120.

This change breaks no tests, and, if I understand
correctly, does not affect user-facing API.

Here is the difference for the `HelloWorldGroupStorage__` struct
generated from macros in the `hello_world` example:

**Before:**

```rs
struct HelloWorldGroupStorage__ {
    pub input_string:std::sync::Arc<<InputStringQuery as salsa::Query> ::Storage> ,pub length:std::sync::Arc<<LengthQuery as salsa::Query> ::Storage> ,
}
```

**After:**

```rs
struct HelloWorldGroupStorage__ {
    input_string:std::sync::Arc<<InputStringQuery as salsa::Query> ::Storage> ,length:std::sync::Arc<<LengthQuery as salsa::Query> ::Storage> ,
}
```
2022-01-23 20:18:25 +00:00
Niko Matsakis
c0d9070a64 refactor _mut path to not take arc
Instead of grabbing the arc, just pass back an `&mut Runtime`.

The eventual goal is to get rid of the lock on the `set` pathway
altogether, but one step at a time.
2022-01-21 13:52:43 -05:00
bors[bot]
e5cb77472b
Merge #290
290: Update doc in macro about query.in_db for dyn db r=nikomatsakis a=mheiber

Update the macro for `query_group` so the comment
on `fn in_db` no longer says that it is more common
to use the trait method on `db`.

Afaict, the trait methods referred to were removed
when dyn database were introduced in RFC0006:
./book/src/rfcs/RFC0006-Dynamic-Databases.md, as
described in the section
"Instead of `db.query(Q)`, you write `Q.in_db(&db)`"

Co-authored-by: Maxwell Elliot Heiber <mheiber@fb.com>
2022-01-21 18:38:10 +00:00
Maxwell Elliot Heiber
eb2b36948d Update doc in macro about query.in_db for dyn db
Update the macro for `query_group` so the comment
on `fn in_db` no longer says that it is more common
to use the trait method on `db`.

Afaict, the trait methods referred to were removed
when dyn database were introduced in RFC0006:
./book/src/rfcs/RFC0006-Dynamic-Databases.md, as
described in the section
"Instead of `db.query(Q)`, you write `Q.in_db(&db)`"
2021-12-30 11:36:05 +00:00
Niko Matsakis
fc020de9c4 s/maybe_changed_since/maybe_changed_after/ 2021-11-13 16:39:41 -05: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
42a653ca6f use computed recovery strategy
Rather than checking return value of from `Q::cycle_fallback`, we
now consult the computed recovery strategy to decide whether to
panic or to recover. We can thus assume that we will successfully
recover and don't need to check for `None` results anymore.
2021-10-30 11:19:09 -04:00
Niko Matsakis
fc826b0689 add cycle_recovery_strategy function on database 2021-10-30 11:09:24 -04:00
Niko Matsakis
d082270610 introduce CYCLE_STRATEGY constant for queries
This allows us to figure out whether a query can recover
from a cycle (and how) without invoking the `recover`
function.
2021-10-30 11:09:24 -04:00
Jonas Schievink
cb38bb7066 Publish 0.17.0-pre.2 2021-10-06 22:33:30 +02:00
Jonas Schievink
7b39882deb Remove dead code 2021-09-03 18:38:34 +02:00
Lukas Wirth
ea378103c3 Use format_ident! when creating new identifiers in salsa-macros 2021-08-24 02:47:28 +02:00
Lukas Wirth
26b47e02e9 Keep parameter names of queries in query_group attribute 2021-06-30 21:14:10 +02:00
Tim Robinson
fc6806a07c CI runs Clippy 2021-06-17 15:21:51 +01:00
Niko Matsakis
d178d1b765 update a few comments that mention gc 2021-06-06 06:20:23 -04:00
Aleksey Kladov
a84ee62bd1 Publish 0.17.0-pre.1
- new cancellation API #265
2021-05-29 20:57:48 +03:00
Jonas Schievink
1fb660c33e Use the more common spelling of cancell{ed,ation} 2021-05-25 15:08:23 +02:00
Jonas Schievink
223f87bb18 Canonicalize to US spelling of "cancelation" 2021-05-18 15:36:43 +02:00
Jonas Schievink
197b01fa4b Implement "opinionated cancellation" 2021-05-17 18:59:28 +02:00
Aleksey Kladov
9e6adc9900 Publish v0.16.0
- #242 allow `dyn Database` to be non-'static
- #248 allow using borrowed keys for invalidation
- #250 upgrade crossbeam_utils
2020-10-14 12:33:39 +02:00
Aleksey Kladov
6b96a1e22f Leverage Cargo defaults 2020-10-14 12:29:29 +02:00
Niko Matsakis
2e2239a307
Merge pull request #242 from Marwes/lift_static_restriction
feat: Allow the dynamic db to be non-static
2020-09-09 10:52:50 -04:00
Aleksey Kladov
590c037323 Release v0.15.2
* #243, better error message from proc macro
* #240, purge method for cleaning the database completely
2020-08-05 13:55:12 +02:00
Chase Wilson
78b32d69da
Made proc-macros panic less
Replaced the panics in query_group with syn errors for better user feedback and experience
2020-07-25 14:38:13 -05:00
Markus Westerlind
3a84a77ebc Remove some unnecessary changes 2020-07-24 11:23:41 +02:00
Markus Westerlind
e2ab6c8bfa feat: Allow the dynamic db to be non-static 2020-07-23 17:08:06 +02:00
Markus Westerlind
ce6428fbbd Lift the static restriction on the traits 2020-07-23 11:34:20 +02:00
Aleksey Kladov
380c4c1dc8 Release v0.15.0
The single (but big) change is Dynamic Database RFC implementation:

https://github.com/salsa-rs/salsa/pull/231
2020-07-07 15:45:39 +02:00
Niko Matsakis
fd036a4f15 do not generate in_db_mut when it is inappropriate 2020-07-06 21:48:14 +00:00
Niko Matsakis
d2e9f64bda add shims for input queries 2020-07-06 21:48:07 +00:00
Niko Matsakis
9596c25b77 move the shims into private, hidden functions 2020-07-06 21:06:36 +00:00
Aleksey Kladov
a5626cd8a0 Force codegen in the query-defning crate 2020-07-06 21:04:07 +00:00
Niko Matsakis
b66eb81311 experiment: extract some Memo code to be independent from Q
This should enable more sharing and less monomorphization. There is
probably room for more radical restructing in this vein.
2020-07-06 00:55:01 +00:00
Niko Matsakis
8ca3ab56b5 update the mdbook documentation, introducing a diagram 2020-07-05 16:45:07 +00: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
d64dfa1727 make for_each_query dyn-safe 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
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
64f3eb96a1 remove GroupKey associated type 2020-07-04 14:16:50 +00:00
Niko Matsakis
1a07944efe remove DatabaseKey associated type 2020-07-04 14:16:50 +00:00
Niko Matsakis
799ddce157 remove unused GroupData associated type 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
7b5ac6e717 implement ability to get readable debug output for DatabaseKeyIndex 2020-07-04 14:16:50 +00:00
Niko Matsakis
5a1bf10ba6 add a query_name associated constant 2020-07-04 14:16:50 +00:00
Niko Matsakis
07623fb962 remove the DatabaseData and associated unsafe code 2020-07-04 14:16:50 +00:00
Niko Matsakis
f7a14f2309 use DatabaseKeyIndex instead of Dependency 2020-07-04 14:16:49 +00:00
Niko Matsakis
206c086bac thread group index to storage initializers 2020-07-04 14:16:14 +00:00
Niko Matsakis
9bd9f8b202 use new with index to create group storage 2020-07-04 14:16:14 +00:00
Niko Matsakis
ebb3769ad2 document the database macro 2020-06-26 22:21:54 +00:00
Edwin Cheng
38e708b68b Fix typo 2020-05-08 14:35:48 +02:00
Veetaha
2c44b6e3a3 Fix typo
Fix typo
2020-02-24 12:50:39 +01:00
Aleksey Kladov
37a3650aef Publish 0.14.1
0.14.0 is broken, as it didn't bump salsa-macros crate.
2019-11-26 11:24:23 +03:00
Niko Matsakis
c789219bc5 move query-storage into an Arc
This way, we can hold a reference to it without borrowing the database.
2019-09-27 05:34:33 -04:00
Niko Matsakis
a9860bf37f
Merge pull request #147 from Marwes/cycles
feat: Allow queries to avoid panics on cycles
2019-09-19 05:56:39 -04:00
Aleksey Kladov
04ecedd6ec ⬆️ syn, quote, proc_macro2 2019-08-22 16:21:46 +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
a0a6bac5af modify public API to set_foo_with_durability 2019-07-02 07:49:01 -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
9d550a9343 track dependencies via direct links to slots 2019-07-02 06:49:24 -04:00
Aleksey Kladov
6d60798eb8 Replace volatile query type with report_untracked_read fn 2019-06-26 13:10:44 +03:00
Niko Matsakis
3534d18c64
Merge pull request #178 from matklad/authors
Change authors to Salsa developers
2019-06-26 06:07:35 -04:00
Aleksey Kladov
10500c8a24 Change authors to Salsa developers
Salsa is a team effort, and builds on a mountain of pre-existing
knowledge!
2019-06-25 13:49:20 +03:00
Aleksey Kladov
149b5faf8a Actually document salsa::requires 2019-06-19 20:12:02 +03:00
Niko Matsakis
e9c787e2b6
Merge pull request #165 from matklad/requires
allow private requirements in query groups
2019-05-30 11:49:41 +02:00
Aleksey Kladov
df92fb794e publish v0.12.1
- Introduce `salsa::transparent` query type(#163)
- Improve salsa proc macro (#160, #162)
- Update parking lot to 0.8.0 (#166)
2019-05-30 11:45:56 +03:00
Aleksey Kladov
6ea5413ef5 switch requires syntax to an attribute 2019-05-21 18:49:18 +03:00
Aleksey Kladov
c816df7208 extract attribute filtering 2019-05-21 18:30:19 +03:00
Aleksey Kladov
940eed92a6 allow private requirements in query groups 2019-05-21 18:04:01 +03:00
Niko Matsakis
8aa01bcccb
Merge pull request #163 from matklad/transparent
Add transparent query type
2019-05-07 11:51:30 -04: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
Taryn
9913b0300e
Remove mention of unsupported '&mut self' for in a query group panic 2019-04-12 16:27:24 -05:00
Roberto Vidal
01c03b85b1 Improve doc comments 2019-04-06 14:23:02 +02:00
Niko Matsakis
30b95dcc24 publish v0.12.0
- Introduce `InternId` as the basis for interned keys, replacing
  `u32` (#157, #158)
- Support keys/values that are not `Send/Sync` (#153)
2019-04-03 16:03:41 -03:00
Niko Matsakis
4b976166fd release 0.11.1
- Includes a fix so that interned keys can be send (#155)
2019-03-27 09:24:55 -04:00
Niko Matsakis
31235aaa96 release 0.11.0
Changes:

- Add interned keys to salsa (#150) -- see salsa-rs/salsa-rfcs#2
  for more details.
- Fix bugs re: GC and volatile queries
- Optimization for GC (#144), though I think this later got undone
  as part of the bug fixes =)
2019-03-27 05:37:26 -04:00
Niko Matsakis
f0d2b964e2 bump syn to 0.15.29
(older versions didn't have the `syn::Result` type, it seems?)
2019-03-22 18:40:35 -04:00
Niko Matsakis
f9fe9e4f07 add missing HasQueryGroup 2019-03-13 05:34:56 -04:00
Niko Matsakis
f48515747c create a true inverse key for the lookup path 2019-03-12 08:55:37 -04:00
Niko Matsakis
e3f5eb6ee8 implement #[salsa::interned] query storage 2019-02-03 20:45:52 +01:00
Niko Matsakis
1736115d9f release 0.10.0
- GC API now more orthogonal + flexible (#138)
- Removed `set_unchecked` testing mechanism (#141)
- Generated enums now squelch `non_camel_case_types` lint (#135)
- Tests now using `set_foo` (#139)
- `Query::group_storage` now called `Query::query_storage` (#142)

Contributors to this release:

- @matklad
- @memoryruins
- @nikomatsakis
2019-01-28 05:06:54 -05:00
Niko Matsakis
58ba8ac425 rename Query::group_storage method to Query::query_storage 2019-01-28 05:01:53 -05:00
Niko Matsakis
1b9aaf2599
Merge pull request #135 from nikomatsakis/non-camel-case-types
apply `non_camel_case_types` to the enum variant
2019-01-26 08:01:35 -05:00
Niko Matsakis
0f2e03d120 apply non_camel_case_types to the enum variant 2019-01-25 19:17:32 -05:00
Niko Matsakis
682c29e777 publish v0.10.0-alpha5
- Make `dyn Trait` implementations work

Contributors to this release:

- @nikomatsakis
2019-01-25 19:09:10 -05:00
Niko Matsakis
6f15a440ca make dyn Trait query implementations work 2019-01-25 18:36:23 -05:00
Niko Matsakis
77c3a72cea Release salsa-0.10.0-alpha4
- Introduce requirement for group storage structs (#130)
- Manually implement Default (#131)

Contributors to this release:

- @cormacrelf
- @nikomatsakis
2019-01-25 11:01:15 -05:00
Niko Matsakis
1b04ac19ff
Merge pull request #131 from cormacrelf/bad-derive-default
Manually implement Default for *GroupStorage
2019-01-25 11:01:01 -05:00
Cormac Relf
868904874a manually implement Default for *GroupStorage
All the example code uses Default to create the db structs, but it turns
out the *GroupStorage's `#[derive(Default)]` adds a trait bound of
(e.g.) `DB__ + Default + HelloWorldDatabase` even though it never
actually needs to call HelloWorldDatabase::default(). So if you didn't
implement Default, then you couldn't be a salsa database struct.
2019-01-26 02:45:07 +11:00
Niko Matsakis
1382495d9f drive-by change: use salsa:: in place of ::salsa::
This is less precise, but it permits people to "re-export" salsa without
forcing a Cargo.toml dependency.
2019-01-25 10:37:59 -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
690a118472 consolidate into one HasQueryGroup trait 2019-01-25 09:21:11 -05:00