Commit graph

1033 commits

Author SHA1 Message Date
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
bors[bot]
a866e71266
Merge #342
342: Make input setters return old value r=nikomatsakis a=MihailMihov

Added an `InputFieldIngredient` which replaces the `FunctionIngredient` for inputs. The end goal is for the inputs to use an ingredient simpler than `FunctionIngredient` and that would allow us to return the old values when updating an input.

Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
2022-08-16 19:26:02 +00: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
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
bors[bot]
648248bd39
Merge #347
347: Track outputs and specified fields r=nikomatsakis a=nikomatsakis

This PR implements a new strategy for tracking output edges and specified fields correctly. Core ideas:

* Track the *outputs* of each query Q and not only its inputs. An output is a specified or assigned field, a created entity, or a pushed accumulator.
* When marking a query Q as validated (no need to execute) in a new revision, you mark ALL of its outputs as validated.

Fixes #338.

The PR also includes some commits that lay the groundwork for #313 and #315 (but I left those for a future PR). In particular, it includes the logic to diff outputs to find values that are no longer output by Q. This will be used to delete obsolete entities. (Originally, I was going to use this to clear outdated outputs of all kinds, but I realized that marking them as validated was a better approach.)

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-13 05:31:11 +00: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
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
85ea35932c update reference chapter
I'm mostly adding this commit to see if I can trick
git into behaving better.
2022-08-13 01:21:45 -04:00
bors[bot]
367c0bfe11
Merge #343
343: Whoops r=nikomatsakis a=nikomatsakis

Revert a bunch of commits I apparently pushed by accident!

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-12 18:33:15 +00:00
Niko Matsakis
5722b333ed Revert "add broken test for specify"
This reverts commit 87ff990774.
2022-08-12 14:28:31 -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
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
bors[bot]
7d8b1881ad
Merge #341
341: add comments, tests, and mild refactorings r=nikomatsakis a=nikomatsakis

This branch contains various bits of work I was doing towards fixing #338 and other such things. I'm opening it now to avoid merge conflicts and because the comments seem useful. 

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-10 04:46:08 +00: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