[#111712] [Ruby master Feature#19322] Support spawning "private" child processes — "kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core" <ruby-core@...>
SXNzdWUgIzE5MzIyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGtqdHNhbmFrdHNpZGlzIChLSiBUc2Fu
14 messages
2023/01/07
[ruby-core:111846] [Ruby master Feature#19346] Add Ractor escape hatch Ractor.disable_isolation_checks! { }
From:
"luke-gru (Luke Gruber) via ruby-core" <ruby-core@...>
Date:
2023-01-17 02:17:19 UTC
List:
ruby-core #111846
Issue #19346 has been updated by luke-gru (Luke Gruber).
Hi, thank you for replying. Rubygems is thread-safe but it doesn't work calling `require` inside a non-main ractor because the rubygems internal logic doesn't follow strict isolation protocol.
----------------------------------------
Feature #19346: Add Ractor escape hatch Ractor.disable_isolation_checks! { }
https://bugs.ruby-lang.org/issues/19346#change-101257
* Author: luke-gru (Luke Gruber)
* Status: Rejected
* Priority: Normal
----------------------------------------
It would be nice to be able to autoload constants inside Ractors. I'm not sure why this is disabled right now because if autoloading is working properly inside threads
then my initial thought is that the autoload implementation should work inside Ractors.
I guess there's different parts to this:
registering the autoload:
```ruby
Ractor.new { autoload :MyClass, 'myclass' }
```
Kicking off the autoload require
```ruby
Ractor.new { MyClass }
```
This leads to the problem of calling rubygems `require` inside Ractors, as rubygems is not Ractor safe.
However, it's thread-safe so it should be able to be ractor safe too (we don't need the ractor isolation checks in rubygems require).
What if there was an API:
```ruby
Ractor.disable_isolation_checks! do
"..."
end
```
It would disable all Ractor isolation errors inside the block. Rubygems could be patched easily and other gems too that
are thread-safe and use synchronization around the class ivars and constants.
Of course it could be abused and would have to be used properly. Well it's just an idea, I'm sure other people have had the same idea before.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/