303: Bump parking_lot packages r=jonas-schievink a=eliascodes
This is motivated by recent changes to `parking_lot` affecting `wasm32-unknown-unknown` targets (see https://github.com/Amanieu/parking_lot/issues/269 if interested). My project depends on `parking_lot` via `salsa`, which is why I'm facing this issue.
TLDR is that `parking_lot` released a new version that provides a fix for the above. I'm hoping that version can be included in a future version of `salsa`.
For reference, here's the relevant part of the changelog: https://github.com/Amanieu/parking_lot/blob/HEAD/CHANGELOG.md#parking_lot-0120-parking_lot_core-090-lock_api-046-2022-01-28
I belive the only changes that might affect APIs used by `salsa` are in PRs https://github.com/Amanieu/parking_lot/pull/313 and https://github.com/Amanieu/parking_lot/pull/344/files, but I'm unfamiliar with the internals of either project so could easily be wrong.
I can build and test successfully locally with these bumps. Let me know if there's anything else I can do to help this over the line.
Co-authored-by: Elias Malik <elias0789@gmail.com>
275: Expose the ability to remove the value from an input query, taking ownership of the value r=nikomatsakis a=1tgr
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
302: fix misleading type in salsa book example r=nikomatsakis a=LYF1999
fix misleading type in salsa book example
Co-authored-by: Yifei <lyfmagic99@gmail.com>
298: when evicting LRU data, keep dep information r=nikomatsakis a=nikomatsakis
and add a test that we do so!
cc `@Veykril` -- this should fix Rust-Analyzer performance
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
292: Document how to tune Salsa r=nikomatsakis a=mheiber
Document how to tune Salsa
> Re the CI failure: I couldn't repro locally with the same command. On CI, mdbook complains it can't find `./rfcs/RFC0007-Opinionated-cancelation.md`
Co-authored-by: Maxwell Elliot Heiber <mheiber@fb.com>
297: Fix netlify deployment r=nikomatsakis a=nikomatsakis
I think I just configured this in a pretty bogus way
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
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>
294: Fix mdbook warning re "Potential incomplete link" r=nikomatsakis a=mheiber
In cycle.md, change `[salsa::Cycle]` to `salsa::Cycle` so mdbook doesn't get confused
and think there is a broken Markdown link ("warning: Potential incomplete link").
After fixing this problem, there are no more mdbook warnings when
running `mdbook build` in the "book" directory.
Co-authored-by: Maxwell Elliot Heiber <mheiber@fb.com>
295: Make storage fields of #nameGroupStorage private r=nikomatsakis a=mheiber
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> ,
}
```
Co-authored-by: Maxwell Elliot Heiber <mheiber@fb.com>
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> ,
}
```
In cycle.md, change `[salsa::Cycle]`
to `salsa::Cycle` so mdbook doesn't get confused
and think there is a broken Markdown link.
The warning was as follows:
```
warning: Potential incomplete link
┌─ cycles.md:3:131
│
3 │ By default, when Salsa detects a cycle in the computation graph, Salsa will panic with a [`salsa::Cycle`] as the panic value. The [`salsa::Cycle`] structure that describes the cycle, which can be useful for diagnosing what went wrong.
│ ^^^^^^^^^^^^^^^^ Did you forget to define a URL for ``salsa::Cycle``?
│
= hint: declare the link's URL. For example: `[`salsa::Cycle`]: http://example.com/`
```
After fixing this problem, there are no more mdbook warnings.
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.
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>
288: Make with_incremented_revision take FnOnce r=nikomatsakis a=mheiber
Removes a bug vector, since this function would
panic if the closure is used more than once.
iuc, the code opted out of the compiler's checks
before via a clever `.take()`.
Another change is to take the closure by value
rather than by reference. The monomorphization
seems harmless, since `with_incremented_revision`
is only called from two places.
289: Remove ': salsa::Database' bound from two examples r=nikomatsakis a=mheiber
Two examples had a superfluous bound
': salsa::Database' that wasn't present
in the `compiler` example and doesn't seem to be needed.
The `query_group` macro adds this bound
automatically.
This change can lead to a trailing `+` in
the bounds list. I verified this is OK by
running the examples and verifying that the production
is allowed
[per the Rust Reference](https://doc.rust-lang.org/reference/trait-bounds.html)
Co-authored-by: Maxwell Elliot Heiber <mheiber@fb.com>
287: Remove unused crossbeam_utils dependency r=nikomatsakis a=DSPOM2
crossbeam_utils is currently not used anywhere withing this crate so I propose to remove the dependency to (slightly) reduce compile times
Co-authored-by: DSPOM2 <61850714+DSPOM2@users.noreply.github.com>
285: Cleanup and fix cycle handling r=nikomatsakis a=nikomatsakis
This PR is...kind of long. It reshapes the core logic of salsa to fix various bugs in cycle handling and generally simplify how we handle cross-thread coordination.
Best read commit by commit: every commit passes all tests, afaik.
The core bug I was taking aim at was the fact that, when you invoke `maybe_changed_since`, you can sometimes wind up detecting a cycle without having pushed some of the relevant queries onto the stack. This is now fixed.
From a user's POV, ~~nothing changes from this PR~~, there are only minimal changes to the public interface. The biggest one is that recover functions now get a `&salsa::Cycle` which has methods for accessing the participants; the other is that queries that are participating in cycle fallback will use unwinding to avoid executing past the point where the cycle is discovered. Otherwise, things work the same as before:
* If you encounter a cycle and all participant queries are marked with `#[salsa::recover]`, then they will take on the recovery value. (At the moment, they continue executing after the cycle is observed, but their final result is ignored; I plan to change this in a follow-up PR, or maybe some future commit to this PR.)
* If you encounter a cycle and some or all participants are NOT marked with `#[salsa::recover]`, then the code panics. This is treated like any other panic, cancelling all other work.
Along the way, I made... a few... other changes:
* Cross-thread handling is simplified. When we block on another thread, it no longer sends us a final result. Instead, it just gets re-awoken and then it retries the original request. This is helpful when you encounter cycles in `maybe_changed_since` vs `read`, but it's also more compatible with some of the directions I have in mind.
* Cycle detection is simplified and more centrally coordinated. Previously, when a cycle was detected, we would mark all the participants on the current thread, but then we would mark other threads 'lazilly'. Now, threads move ownership of their stack into the shared dep graph when they block, so that we can mark all the stack frames at once. This also means less cloning on blocking, so it should be mildly more efficient.
* The code is DRY-er, since `maybe_changed_since` has been re-implemented in terms of the same core building blocks as `read` (`probe` and friends). I originally tried to unify them, but I realized that they behave somewhat differently from one another and both of them make sense. (In particular, we want to be able to free values with the LRU cache while still checking if they are up to date.)
Ah, I realize now that I had planned to write a bunch of docs in the salsa book before I landed this. Well, I'm going to open the PR anyway, as I've let this branch go far too long.
r? `@matklad`
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
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)`"
Two examples had a superfluous bound
': salsa::Database' that wasn't present
in the `compiler` example.
The `query_group` macro adds this bound
automatically.
This change can lead to a trailing `+` in
the bounds list. I verified this is OK by
running the examples and verifying that the production
is allowed
[per the Rust Reference](https://doc.rust-lang.org/reference/trait-bounds.html)