Skip to content

[interpreter] Threading #179

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

Merged
merged 9 commits into from
Aug 6, 2021
Merged

[interpreter] Threading #179

merged 9 commits into from
Aug 6, 2021

Conversation

rossberg
Copy link
Member

@rossberg rossberg commented Jul 26, 2021

This adds threading support to the interpreter:

  • Add threads to evaluator and script runner, with randomised execution.
  • Add thread and wait script commands for spawning and joining threads.
  • Add either result pattern for testing non-deterministic results.
  • Extend JS harness with new functions thread and wait (not yet fleshed out).
  • Add a trivial test.
  • Added command line flags for setting non-determinism random seed.

This includes scripting functionality as discussed in #163. However, I decided to make sharing more explicit with (sharing ...) annotations in a thread definition, because it's more readable, avoids funny errors, and it's probably gonna be easier to implement in the JS converter that way. See test for how it's used.

Sorry for the large PR, this required more refactoring than I anticipated. In particular, the whole script runner had to effectively be transformed from big step to small step. Similarly, Eval.invoke and Eval.init needed to become small steps.

@rossberg rossberg requested a review from conrad-watt July 26, 2021 08:16
@SuspendedPhan
Copy link

Sorry for the noise, but just wanted to say seriously thanks for working on this! golang said they would implement threads once this moves to stage 3 :D

-- excited adopter of wasm

Copy link
Collaborator

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

Is it possible to lift the either combinator so that it applies to lists of values, rather than individual values (see comment on multi-value below)?

Copy link
Collaborator

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

LGTM

I see that wait/notify implementations are stubbed out - would these need refactorings to implement?

@rossberg
Copy link
Member Author

rossberg commented Aug 6, 2021

I see that wait/notify implementations are stubbed out - would these need refactorings to implement?

Good question, I don't know. I hope not.

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.

3 participants