Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable parallel tests #527

Merged
merged 19 commits into from
Jul 25, 2024
Merged

re-enable parallel tests #527

merged 19 commits into from
Jul 25, 2024

Conversation

nikomatsakis
Copy link
Member

This branch re-enables the parallel tests. It does not yet add the nicer parallel APIs imagined for Salsa 3.0.

Changes:

  • The per-thread state is now stored in thread-local variables.
  • To create a per-thread 'snapshot', you store the database in a salsa::Handle, which can simply be cloned.
  • When the get_mut method on the Handle is called, any outstanding clones will be cancelled (I added a test for this).

We are using "peek fields" methods instead;
I like that approach better.
We are going to want to take databases at
public entry points.
We can use this to more reliably sort.
We used to sort just by the ingredient index,
but since those are now added dynamically,
that can be fairly unstable in some of the tests.
We now sort by the "debug name" of the ingredient
first, which is more reliably stable.
I realized there weren't any!
Copy link

netlify bot commented Jul 24, 2024

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit bf636d2
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/66a21c0f652bca0008219667

Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of a handle. It also removes the need for implementing a snapshot function on any other field stored on Db (which normally involves wrapping that field in an Arc).

The only thing that I'm slightly concerned about is the cost of using thread locals for every Salsa operation.

src/handle.rs Outdated
@@ -49,6 +49,12 @@ impl<Db: HasStorage> Handle<Db> {
let storage = self.db.storage();
storage.runtime().set_cancellation_flag();

self.db.salsa_event(Event {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could probably use an AtomicUsize for clones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could, we do need a mutex for signalling. This is simpler.

@nikomatsakis
Copy link
Member Author

thread 'parallel_cancellation::execute' panicked at /home/runner/work/salsa/salsa/src/handle.rs:39:36:

interesting, I don't see this...

@nikomatsakis nikomatsakis added this pull request to the merge queue Jul 25, 2024
Merged via the queue into salsa-rs:master with commit e4ce917 Jul 25, 2024
7 of 8 checks passed
@nikomatsakis nikomatsakis deleted the spindle branch July 28, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants