Commit graph

112 commits

Author SHA1 Message Date
bors[bot]
38c9b612dd
Merge #378
378: Derive DebugWithDb r=nikomatsakis a=agluszak

Closes #317 

Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2022-08-24 10:37:09 +00:00
Andrzej Głuszak
0c3084d009 Test cleanup 2022-08-24 00:01:44 +02:00
Andrzej Głuszak
fbb219a527 Add a test 2022-08-23 23:54:18 +02:00
bors[bot]
9677935c9c
Merge #374
374: Add test for durability r=nikomatsakis a=crlf0710

Fixes #339 .

Co-authored-by: Charles Lew <crlf0710@gmail.com>
2022-08-23 19:23:51 +00:00
Charles Lew
8d956a8229 Add test for durability 2022-08-22 21:50:58 +08: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
Charles Lew
7267452ff1 Implement Setter API 2022-08-22 19:22:47 +08:00
XFFXFF
74e220ec39 update some tests 2022-08-22 15:32:29 +08:00
zjp
dfee2b8cee update tests 2022-08-22 15:23:58 +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
XFFXFF
e856f565b3 create inputs first in an lru test 2022-08-22 08:21:51 +08:00
XFFXFF
31a4c68fc7 fix typos: deponds -> depends 2022-08-22 05:53:25 +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
6645774d55 port another test about lru 2022-08-21 14:02:51 +08:00
XFFXFF
04b70f54e3 lru can be changed at runtime 2022-08-21 10:02:45 +08:00
Mihail Mihov
6b1d24098b Add test override_new_get_set 2022-08-21 01:52:54 +03:00
XFFXFF
738dc3f878 test for compile failure: lru can not be used with specify 2022-08-19 07:13:03 +08: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
XFFXFF
fc4d531d76 refactor and cargo fmt 2022-08-18 08:07:13 +08:00
Niko Matsakis
70b50a1813 fix formatting 2022-08-17 07:38:03 -04:00
Niko Matsakis
f147ee3917 demonstrate re-use workaround 2022-08-17 06:55:27 -04: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
2a9f0f7140 add accumulation test
I can't seem to get it to perform incorrectly lol,
what am I missing.
2022-08-17 04:43:25 -04:00
XFFXFF
2778750fdf add a broken test for lru 2022-08-17 07:22:45 +08:00
Niko Matsakis
f2a67ae527 update expected logs
input fields no longer generate WillCheckCancellation events
2022-08-16 17:58:51 -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
Mihail Mihov
07dd72470e Rename compare_and_swap to mutate_in_place 2022-08-14 20:24:57 +03:00
Mihail Mihov
5e79fb42e3 Add "compare and swap" test 2022-08-13 18:22:44 +03: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
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
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
b65207ccbc add broken test for specify
We specify the value for the field in 1 rev but
fail to specify in the next revision. The old value
is (currently) never cleared.
2022-08-13 01:21:45 -04:00
Niko Matsakis
5722b333ed Revert "add broken test for specify"
This reverts commit 87ff990774.
2022-08-12 14:28:31 -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
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
87ff990774 add broken test for specify
We specify the value for the field in 1 rev but
fail to specify in the next revision. The old value
is (currently) never cleared.
2022-08-10 01:45:15 -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
27a240aa86 comment out red_herring tests
They do not pass (yet)
2022-08-10 00:42:32 -04:00
Niko Matsakis
7e747f357c enable logging for tracked-fn-read-own-entity test 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
00172efb19 add red-herring tests which modify distinct inputs 2022-08-10 00:42:05 -04:00
bors[bot]
9ff6fb3376
Merge #336
336: Add options to tracked functions for cycle recovery r=nikomatsakis a=XFFXFF

closes #331 

This pr ports the old salsa tests for cycle in a single thread, except for [cycle_disappears_durability](03a27a7054/tests/cycles.rs (L326)), since we don't have the api that permits setting durability.  

~I haven't ported parallel related tests, which would be some work, wondering if we can merge this in first~

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-10 04:14:16 +00:00
XFFXFF
d32cff1bfb define Jar struct separately 2022-08-10 07:28:13 +08:00
XFFXFF
9feb0050e4 ports parallel related tests for cycle 2022-08-09 18:06:39 +08:00
XFFXFF
9fb5f7a366 add some comments 2022-08-09 08:43:44 +08:00
XFFXFF
80bfff8d7a port old tests for cycle in a single thread 2022-08-09 07:54:15 +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
XFFXFF
815bf6003b add a test 2022-08-08 07:20:39 +08:00
XFFXFF
1ec4e45a7f test: expect reuse field X changes but fn depends on field Y 2022-08-07 12:43:45 +08:00
Niko Matsakis
3b3e0be981 make salsa-2022 tests into independent files
also add a few new tests
2022-08-06 10:43:43 -04:00
Niko Matsakis
e0c3109d6a add a test where we change the input 2022-08-06 02:27:20 -04:00
Niko Matsakis
fa2d24a0be squash (some) warnings 2022-08-05 14:32:12 -04:00
Niko Matsakis
66f1f1c50c rename salsa-entity to salsa-2022 2022-08-05 13:20:14 -04:00
Niko Matsakis
11fb9823cc remove blank line 2022-08-05 02:57:22 -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
89f801276c another simple test 2022-08-05 00:41:00 -04:00
Niko Matsakis
627eddd428 add a test for tracked functions 2022-08-05 00:39:00 -04:00