-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Description
What language does this apply to?
Ruby
Describe the problem you are trying to solve.
Be able to use Protobuf objects inside of Ruby Ractors.
Describe the solution you'd like
Today, you get things like:
`method_missing': ractor unsafe method called from not main ractor
This is because by default every C extension is considered ractor-unsafe at definition time by default (see ruby/ruby#3824), so Google::Protobuf::AbstractMethod#method_missing
as a C method is considered unsafe. They are considered unsafe by default because Ractors are parallel without GVL/GIL and therefore the C extensions must be thread safe within themselves. It appears Protobuf implementation is (not to be confused with general thread safety), so rb_ext_ractor_safe(true);
can be called at the top of
__attribute__((visibility("default"))) void Init_protobuf_c() { |
Also make a test for creation and use of Protobuf objects inside Ractors (bonus points for making the objects RUBY_TYPED_FROZEN_SHAREABLE
and testing they can be made shareable). That way the FFI-based implementation can be confirmed Ractor-safe as well.
Also, assuming Ractor support is easily added for both implementations, would a PR to support this be welcomed? And backported to the 3.x series (but if not that's ok)?