Commit graph

483 commits

Author SHA1 Message Date
Jack Rickard
c58ff26d87
Simplify interning by restricting deletes 2022-09-25 22:33:37 +01:00
XFFXFF
cc6ab647fa refactor outputs method of LocalState 2022-09-25 01:21:39 +00:00
XFFXFF
e7c7f386fe fix accumulator: clear the outdated accumulated values 2022-09-25 00:24:16 +00:00
XFFXFF
1214610451 remove inputs method of QueryEdges 2022-09-24 23:59:25 +00:00
XFFXFF
a2be847e1a remove unused variables and functions 2022-09-24 23:59:25 +00:00
XFFXFF
d71892c047 update diff output 2022-09-24 23:59:25 +00:00
XFFXFF
961c4ce154 update some tests and run cargo fmt 2022-09-24 23:59:25 +00:00
XFFXFF
98d1be0650 mark the outputs as valid as we encounter them in deep_verify_memo 2022-09-24 23:59:25 +00:00
XFFXFF
c219944699 merge input/output lists into one list 2022-09-24 23:59:25 +00:00
XFFXFF
1ae6a7bbc5 use Assigned insread of Field and remove Field 2022-09-24 23:59:25 +00:00
XFFXFF
99cfca5799 add the fields of tracked struct to the output of queries 2022-09-24 23:59:25 +00:00
XFFXFF
4c4096e39b panic when reading fields of tracked structs from older revisions 2022-09-24 23:59:25 +00:00
Niko Matsakis
684ab6f4fe
Update components/salsa-2022/src/input.rs 2022-09-17 06:44:11 -04:00
OLUWAMUYIWA
4bb4262569 cargo fmt 2022-09-16 15:02:15 +01:00
OLUWAMUYIWA
0f21bf0fd8 made singleton struct panic upon duplication and added tests to immutable fields 2022-09-16 14:53:56 +01:00
Onigbinde Oluwamuyiwa Elijah
e3661de899
Merge branch 'salsa-rs:master' into immutable_fields_in_inputs 2022-09-16 01:53:42 +01:00
Jack Rickard
79823c7f65
Fix deadlock in InternedIngredient::intern 2022-09-16 00:10:33 +01:00
Jack Rickard
f1499a20e2
Fix unsoundness in input_field.rs 2022-09-15 21:25:54 +01:00
Jack Rickard
5b8464c4f9
Support on-demand inputs
This adds initial support for on-demand inputs by allowing new inputs to
be created with only a shared reference to the database. This allows
creating new inputs during a revision and therefore from inside tracked
functions.
2022-09-15 21:25:53 +01:00
OLUWAMUYIWA
32f0ce0cff better debugging for input structs by including id fields 2022-09-14 14:45:59 +01:00
Bernardo Uriarte
bed692e50e simplify and avoid duplication 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
3f74f36418 format 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
378090acc8 add documentation back 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
a288c40034 simplify paths 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
84445d5120 propagate include_all_fields option 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
d57c3d36b8 add documentation 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
f4c6f4126e make DebugWithDb::debug only read identiy fields
and add `DebugWithDb::debug_all` which reads all fields
2022-09-13 18:01:19 +02:00
Jack Rickard
61e3bdfc81
Fix race condition in interned data
In some scenarios the `InternedIngredient` could return two different
ids for the same data if called in parallel.
2022-09-13 00:58:17 +01:00
OLUWAMUYIWA
42a996dd8d added singleton to tecked_fn AllowedOptions impl 2022-09-11 09:22:09 +01:00
Onigbinde Oluwamuyiwa Elijah
fac05b3c9f
Merge branch 'salsa-rs:master' into singleton 2022-09-11 09:12:17 +01:00
Jack Rickard
5832ad3090
Replace () with Singleton Salsa struct 2022-09-06 00:34:00 +01:00
Jack Rickard
a9e24d8b0d
Allow "constant" tracked functions
This adds support for tracked functions with only a database as input,
that is, it does not take a salsa struct.
2022-09-06 00:33:43 +01:00
bors[bot]
bd7f27d72b
Merge #406
406: no need to generate a config struct for each field of `salsa::input` r=nikomatsakis a=XFFXFF

https://github.com/salsa-rs/salsa/pull/342 added `InputFieldIngredient` which replaces the `FunctionIngredient` for `salsa::input`, so we don't need to generate a config struct and `salsa::function::Configuration` impl for each field, beacuse they are only needed when we use `FunctionIngredient`

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-09-05 10:49:33 +00:00
bors[bot]
e0d07812fa
Merge #392
392: Allow creation of tracked methods r=nikomatsakis a=Skepfyr

Fixes #319.

This allows users to annotate impl blocks with `#[salsa::tracked]` and
then create tracked methods by marking individual functions with
`#[salsa::tracked]`.

Note this requires your code that looks like:
```rust
#[salsa::tracked(jar = Jar)]
impl MyInput {
    #[salsa::tracked]
    fn tracked_fn(self, db: &dyn Db) -> u32 {
        self.field(db) * 2
    }
}
```
You get an error if you annotate a method with `#[salsa::tracked]` but forget to mark the impl block.

It got messier than I was hoping but I think it turned out alright, this would look really pretty if we had [inherent associated types](https://github.com/rust-lang/rust/issues/8995), but we don't. Annoyingly even if that landed I think we'd still need the attribute on the impl block just so that it was possible to create the associated struct somewhere as you can't put types inside an impl block (and they aren't accessible if placed inside a function).

Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
2022-09-05 10:44:51 +00:00
XFFXFF
b55caff4ec no need to generate a config struct and corresponding impls for each field of salsa::input 2022-09-05 14:10:46 +08:00
Jack Rickard
bac4c668cf
Add more tests for tracked methods 2022-09-03 15:44:56 +01:00
Onigbinde Oluwamuyiwa Elijah
aa25761bd4
Merge branch 'salsa-rs:master' into singleton 2022-09-03 14:37:27 +01:00
OLUWAMUYIWA
975fc9d4ab ran cargo fmt 2022-09-03 14:32:42 +01:00
OLUWAMUYIWA
25809151dd removed AllowedMode trait and added compile-fail tests 2022-09-02 13:09:28 +01:00
OLUWAMUYIWA
3ca70e6b04 cargo fmt 2022-09-02 03:02:51 +01:00
OLUWAMUYIWA
565c53d4dd Support singleton inputs 2022-09-02 02:54:21 +01:00
Jack Rickard
2df88d2c33
Use #[salsa::tracked] for tracked methods
This changes tracked methods from being annotated with `#[tracked]` to
`#[salsa::tracked]`. This improves consistency and allows outputting a
nicer error message if someone forgets to put the attribute on the impl
block.
2022-08-31 23:30:49 +01:00
Mihail Mihov
55f20344d1 Use visibility of field in SalsaField in #[salsa::interned] getters 2022-08-31 23:49:09 +03:00
Mihail Mihov
3df74dc0ac Use visibility of field in SalsaField in #[salsa::tracked] struct getters and setters 2022-08-31 23:48:53 +03:00
Mihail Mihov
784828ec42 Use visibility of field in SalsaField in #[salsa::input] getters and setters 2022-08-31 22:59:37 +03:00
Mihail Mihov
3542f2a1e7 Add methods in SalsaField and SalsaStruct to get visibility of field 2022-08-31 22:58:56 +03:00
Bernardo Uriarte
fd71561981 reduce amount of generated code for DebugWithDb
by moving part of it to `salsa-2022`
2022-08-30 18:03:18 +02:00
bors[bot]
1cabfdb077
Merge #390
390: Add some doc on `specify` r=nikomatsakis a=XFFXFF

Add some documentation to explain why `specify` only works if the key is a tracked struct created in the current query, as per [this](https://salsa.zulipchat.com/#narrow/stream/146365-good-first-issue/topic/questions.20about.20.60specify.60/near/295416521) zulip thread.  
I also added some tests to test that "specify" shouldn't work in some cases.

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-30 10:17:28 +00:00
Jack Rickard
dbc4154419
Allow creation of tracked methods
This allows users to annotate impl blocks with `#[salsa::tracked]` and
then create tracked methods by marking individual functions with
`#[tracked]`.
2022-08-28 23:28:30 +01:00
XFFXFF
f46f2ac202 fix typos 2022-08-27 07:52:18 +08:00
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