Commit graph

1050 commits

Author SHA1 Message Date
Niko Matsakis
35ddd36b49 move the stack instead of cloning
Currently, when one thread blocks on another, we clone the
stack from that task. This results in a lot of clones, but it also
means that we can't mark all the frames involved in a cycle atomically.
Instead, when we propagate information between threads, we also
propagate the participants of the cycle and so forth.

This branch *moves* the stack into the runtime while a thread
is blocked, and then moves it back out when the thread resumes.
This permits the runtime to mark all the cycle participants at once.
It also avoids cloning.
2021-10-30 11:35:04 -04:00
Niko Matsakis
e83bae717d have runtime coordinate blocking
Instead of creating a future for each edge
in the graph, we now have all dependent queries
block in the runtime and wake up whenever results
are published to see if their results are ready.

We could certainly allocate a CondVar for each dependent
query if we found that spurious wakeups were a problem.
I consider this highly unlikely in practice.
2021-10-30 11:32:56 -04:00
Niko Matsakis
3c094d2932 midpoint: make runtime take wait-result
Thi sis an intermediate step towards having the runtime
coordinate wakeups.
2021-10-30 11:31:18 -04:00
Niko Matsakis
21cb4ef9d6 move WaitResult to runtime
We are going to make it so that the runtime
coordinates delivery of the WaitResults.
2021-10-30 11:31:16 -04:00
Niko Matsakis
f5a15e55c6 rework the dep-graph API to take the lock
This will allow me to add condvar logic to it
2021-10-30 11:30:21 -04:00
Niko Matsakis
213e16f4ee remove explicit Default impl 2021-10-30 11:30:21 -04:00
Niko Matsakis
ba6165726b rename labels to query_dependents 2021-10-30 11:30:21 -04:00
Niko Matsakis
ec38398991 extract the depends_on helper function
Make `add_edge` infallible
2021-10-30 11:30:21 -04:00
Niko Matsakis
e870d02da1 make the dep-graph not generic
Being generic over the keys made code harder to read.
2021-10-30 11:30:21 -04:00
Niko Matsakis
da188fe609 extract DependencyGraph into its own module 2021-10-30 11:30:12 -04:00
Niko Matsakis
2d7a84b4f4 silence lint 2021-10-30 11:27:04 -04:00
Niko Matsakis
66b26f07c2 introduce Retry probe result
Instead of sending the result back, just have the waiting threads retry
reading the cache.
2021-10-30 11:27:04 -04:00
Niko Matsakis
eb1e06d61d fix typo that's always bugging me 2021-10-30 11:27:04 -04:00
Niko Matsakis
0298163211 move CycleError to the plumbing module 2021-10-30 11:27:04 -04:00
Niko Matsakis
79f8acc3aa improve parallel cycle tests
Before we could not observe the case where:

* thread A is blocked on B
* cycle detected in thread B
* some participants are on thread A and have to be marked

(In particular, I commented out some code that seemed necessary and
didn't see any tests fail)
2021-10-30 11:27:04 -04:00
Niko Matsakis
187bd54fa9 move CycleError to plumbing 2021-10-30 11:27:01 -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
7b9c383eb0 improve parallel cycle tests
They now use signals to guarantee we are testing the code paths
we want to be testing.
2021-10-30 11:15:08 -04:00
Niko Matsakis
b4a04531a9 document what we are testing, rename variables 2021-10-30 11:10:10 -04:00
Niko Matsakis
bcffa4a836 find cycle recovery strategy for a given cycle 2021-10-30 11:10:07 -04:00
Niko Matsakis
fc826b0689 add cycle_recovery_strategy function on database 2021-10-30 11:09:24 -04:00
Niko Matsakis
e49088644d introduce cycle_recovery_strategy function
Find the cycle recovery strategy for a given DatabaseKey.
2021-10-30 11:09:24 -04:00
Niko Matsakis
853006fccf isolate find_cycle_participants into its own fn 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
Niko Matsakis
7b4ee6fc34 improve panic error message 2021-10-30 11:09:08 -04:00
Niko Matsakis
40139abc24 enable debug logging in the cycles tests 2021-10-30 11:09:08 -04:00
Niko Matsakis
b72b251240 add should-panic annotations to cycle tests that fail 2021-10-30 11:09:08 -04:00
Aleksey Kladov
0f3bc72ec0 Add tests for "dynamic" cycles
If I am not in an error, all current tests uses "static" cycles -- a
cycle always present. Let's spice that up by adding conditional cycles:
cycles that appear only for specific impls
2021-10-30 11:09:05 -04:00
Florian Diebold
ae8348c4f1 Add failing test for cycle revalidation 2021-10-30 11:07:40 -04:00
bors[bot]
2ae813e9ef
Merge #283
283: Publish 0.17.0-pre.2 r=jonas-schievink a=jonas-schievink

User-facing changes since 0.17.0-pre.1:

- https://github.com/salsa-rs/salsa/pull/267
- https://github.com/salsa-rs/salsa/pull/276
- https://github.com/salsa-rs/salsa/pull/280

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:37:14 +00:00
Jonas Schievink
cb38bb7066 Publish 0.17.0-pre.2 2021-10-06 22:33:30 +02:00
bors[bot]
5b4710cb27
Merge #282
282: Update book workflow r=nikomatsakis a=mbrobbel

I noticed the book workflow [failing](https://github.com/salsa-rs/salsa/runs/3568827495?check_suite_focus=true) on master. This PR attempts to fix the failing workflow and prevent failing book deploys in the future.

- Add the book build to `bors.toml`.
- Make sure the book workflow runs for the bors branches (`staging` and `trying`).
- Exclude the bilibili domain in the mdbook-linkcheck config to prevent the 403s.

I also bumped mdbook and mdbook-mermaid versions.

Co-authored-by: Matthijs Brobbel <m1brobbel@gmail.com>
2021-09-30 21:37:31 +00:00
Matthijs Brobbel
b94a5f166c
Update book workflow 2021-09-28 22:03:05 +02:00
bors[bot]
bba8dd57da
Merge #281
281: Add bilibili videos links into book r=nikomatsakis a=armoha

Fixes #278 


Co-authored-by: armoha <kein0011@naver.com>
2021-09-10 15:33:58 +00:00
armoha
ec7a3ae3c3 Add bilibili videos links into book 2021-09-10 05:39:10 +09:00
bors[bot]
a6f9a8a44c
Merge #280
280: Fix `invalidate` and `report_synthetic_read` r=nikomatsakis a=jonas-schievink

Fixes https://github.com/salsa-rs/salsa/issues/246
Fixes https://github.com/salsa-rs/salsa/issues/277

`report_synthetic_read` only forced the durability of the current query to some lower value, but didn't set its `changed_at` value, leading to downstream queries assuming that they could reuse the query's value when they could not. Force `changed_at` to the current revision to fix that. This will not result in unnecessary invocations of the query, because salsa still treats it as pure, and won't re-run it if its inputs are up to date.

Additionally, `invalidate` did also not set the slot's `changed_at` field, which is fixed by setting it to the newly created revision.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-09 16:10:06 +00:00
Jonas Schievink
8f0b9b7f82 Fix invalidate and report_synthetic_read 2021-09-03 23:35:15 +02:00
bors[bot]
aed4bbff73
Merge #279
279: Remove dead code r=nikomatsakis a=jonas-schievink

This was added in fd036a4f15, but never actually came into effect.

Granting access to `QueryTableMut` for every query type should be harmless, because every method on that type has a where-clause that makes it only work with the right query storage type.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-09-03 18:10:16 +00:00
Jonas Schievink
7b39882deb Remove dead code 2021-09-03 18:38:34 +02:00
bors[bot]
114d6db8f6
Merge #276
276: Keep parameter names of queries in `query_group` attribute r=nikomatsakis a=Veykril

Now that RA gets to a point where it can expand attributes it would be helpful not to discard parameter names.
Before:
![Code_1XD5LiRfJw](https://user-images.githubusercontent.com/3757771/123661119-9420ab00-d834-11eb-8d59-296533e0a96e.png)
After:
![Code_kwRhvPySuL](https://user-images.githubusercontent.com/3757771/123661116-93881480-d834-11eb-88e4-b8e4dbf2be52.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-08-24 19:51:37 +00: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
bors[bot]
6db6c3c4d0
Merge #271
271: CI runs Clippy r=nikomatsakis a=1tgr



Co-authored-by: Tim Robinson <tim.g.robinson@gmail.com>
2021-06-17 14:26:14 +00:00
bors[bot]
08cddfd6dd
Merge #272
272: CI installs `rustfmt` where needed r=nikomatsakis a=1tgr

Only the stable toolchain appears to install `rustfmt` by default

Co-authored-by: Tim Robinson <tim.g.robinson@gmail.com>
2021-06-17 14:24:35 +00:00
Tim Robinson
fc6806a07c CI runs Clippy 2021-06-17 15:21:51 +01:00
Tim Robinson
a691096063 CI installs rustfmt where needed
Only the stable toolchain appears to install `rustfmt` by default
2021-06-17 15:10:45 +01:00
bors[bot]
5c20caaab4
Merge #268
268: Expose proc macro docs via the main crate r=nikomatsakis a=1tgr

Improve visibility by placing the `database` and `query_group` proc macros at the bottom of the main docs page, instead of manually browsing to the docs for the `salsa-macros` crate.

Co-authored-by: Tim Robinson <tim.g.robinson@gmail.com>
2021-06-17 13:40:35 +00:00
bors[bot]
7c4bc51165
Merge #270
270: CI runs `cargo fmt` in check mode r=nikomatsakis a=1tgr



Co-authored-by: Tim Robinson <tim.g.robinson@gmail.com>
2021-06-17 13:37:42 +00:00
Tim Robinson
de030b0a69 CI runs cargo fmt in check mode 2021-06-16 19:26:16 +01:00
Tim Robinson
c6e4b23c71 Expose proc macro docs via the main crate 2021-06-16 09:50:05 +01:00