5 ms·
Tl;dr The goal is to keep compatibility with Ruby 2. It introduces the concept of guilds and channels to send objects between guilds. The bullet points below ar
by pmontra 10y ago
Tl;dr The goal is to keep compatibility with Ruby 2. It introduces the concept of guilds and channels to send objects between guilds. The bullet points below are quoted from a couple of slides, the other text is mine:
* Guild has at least one thread (and a thread has at least one fiber)
* Threads in different guilds can run in parallel
* Threads in a same guild can not run in parallel because of GVL (or GGL: Giant Guild Lock)
A guild can't access the objects of other guilds.
About channels:
* We have Guild::Channel to communicate each other
* 2 communication methods
1. Copy
2. Transfer membership or Move in short
Copy is a deep copy and the object is duplicated into the destination guild. A transfer removes an object from a guild and makes it available to another.
There are also immutable objects that are available to all guilds. An obvious example are numbers, which are objects in Ruby, booleans and symbols. I think that other objects are frozen with https://ruby-doc.org/core-2.3.1/Object.html#method-i-freeze https://ruby-doc.org/core-2.3.1/Object.html#method-i-freeze
They already did some encouraging benchmarks.
- azr79 10y agosounds reasonable to me
- bad_user 10y agoSo guilds are effectively OS-managed processes?
- pmontra 10y agoFrom the slides I got the idea that there is only one OS process with guilds and possibly threads within guilds. But it could be that the language doesn't care and that's an implementation detail. We'll see.
- audunw 10y agoNo, the heap is shared among guilds. See the last slide. Moving data between guilds is cheap because data does not have to be copied. Referencing frozen (immutable) data is cheap to. It seems it will track ownership of objects to make sure guilds don't access other guilds data. But it doesn't seem that it uses OS-level data protection.
- catnaroek 10y ago> A guild can't access the objects of other guilds. > 2. Transfer membership or Move in short How is this enforced? What exactly happens at runtime if a guild tries to manipulate an object that belongs to another? (Absent a compile-time check, this is always a possibility.)
- riffraff 10y agoyou get a runtime error
- catnaroek 10y agoIs it a guaranteed runtime error, or a best-effort thing, à la Java's ConcurrentModificationException?
- pmontra 10y agoIt's similar to Rust's transfer of ownership. Rust is compiled so you get a compile time error if you try to access something you can't access anymore. Check the code at http://rustbyexample.com/scope/move.html http://rustbyexample.com/scope/move.html and run it (inside the page). There is a commented out println towards the end. Comment it in, run the code again and see the compiler error. More about transfer of ownership at https://doc.rust-lang.org/book/ownership.html https://doc.rust-lang.org/book/ownership.html
- rst 10y agoSlides also note that treatment of some state in pre-existing Ruby code, e.g., instance variables of class objects, gets messy. (Class variables are listed as per-Guild, but a fair amount of Ruby code uses instance vars on class objects instead.)
- _ko1 10y agoSo we need to rewrite to support multi-guilds application.