Skip to content

Mark the Gem as Ractor safe#160

Merged
jbourassa merged 4 commits intobytecodealliance:mainfrom
macournoyer:ractor
Mar 29, 2023
Merged

Mark the Gem as Ractor safe#160
jbourassa merged 4 commits intobytecodealliance:mainfrom
macournoyer:ractor

Conversation

@macournoyer
Copy link
Copy Markdown
Contributor

Just need to call rb_ext_ractor_safe in init.

An extension is Ractor safe if it has no global variables.

See https://docs.ruby-lang.org/en/master/extension_rdoc.html#label-Appendix+F.+Ractor+support

Note that all objects have to be created inside the Ractor, as the engine, store, etc. are not shareable (yet?). But it works!

See https://docs.ruby-lang.org/en/master/extension_rdoc.html#label-Appendix+F.+Ractor+support

There is no global variable, so no problems. But all objects have to be created inside the Ractor, as none are shareable. I don't know how we could make that work.
Copy link
Copy Markdown
Collaborator

@jbourassa jbourassa left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

Conceptually I think we could make the Module and the Engine Ractor-shareable without too much trouble, but I haven't given it much thought.

@jbourassa jbourassa merged commit 1009e0b into bytecodealliance:main Mar 29, 2023
@macournoyer
Copy link
Copy Markdown
Contributor Author

macournoyer commented Mar 29, 2023

Store too it seems! Almost got it working... Will send another PR when I do. Thanks Jimmy 🙌

EDIT: Well no... what was I thinking. Store cannot be shared.

@macournoyer macournoyer deleted the ractor branch March 29, 2023 20:58
ianks added a commit that referenced this pull request Mar 31, 2023
* main:
  Update all Ruby packages with `bundle update`
  Update all cargo packages with `cargo update -p`
  Update Wasmtime
  Lint Engine
  Test multiple Ractors at once
  Replace Engine refcell with a mutex
  Fix potential GC bug when expiring the caller
  Allowing making Module and Engine Ractor shareable
  Mark the Gem as Ractor safe (#160)
  use Magnus macros to implement TypedData trait
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