118 ms·
It's somewhat similar to the GIL removal effort in Ruby [1] They are isolating the GIL into Guilds there, which are containers for language threads sharing the
by pmontra 8y ago
It's somewhat similar to the GIL removal effort in Ruby [1]
They are isolating the GIL into Guilds there, which are containers for language threads sharing the same GIL. They are providing two primitives for communication between threads in different guilds. Send, for immutable data (zero copy) and move, for mutable data (copy). They remove the need for the boiler plate code for marshalling and unmarshalling. However I bet that there will be some library to hide that code in Python too.
[1] http://www.atdot.net/%7Eko1/activities/2018_RubyElixirConfTaiwan.pdf http://www.atdot.net/%7Eko1/activities/2018_RubyElixirConfTa...
- riffraff 8y agoIIUC, python's sub-interpreters won't have a `move`. That might not be a bad idea because I am worried `move` will end up being problematic in ruby, but time will tell.
- AlexTWithBeard 8y agoCopy + move looks like a typical function call to me: pass in a bunch of immutable arguments, return a result. Such approach would cover many, if not most user cases for multithreading.
- rocqua 8y agoWhat happens when the caller modifies the read only arguments while the function is running?
- pmontra 8y agoI'm not sure if this the question you're asking but in Ruby the program fails. gsub! is a method of String that mutates the object (vs gsub which returns a new string) freeze is a method that makes immutable the object it's called upon. 2.3.0 :001 > def replace_a_with_b(s) 2.3.0 :001?> s.gsub!("a", "b") 2.3.0 :001?> end => :replace_a_with_b 2.3.0 :002 > replace_a_with_b("abc") => "bbc" 2.3.0 :003 > replace_a_with_b("abc".freeze) RuntimeError: can't modify frozen String from (irb):20:in `gsub!' from (irb):20:in `replace_a_with_b' from (irb):23 from /home/me/.rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'
- XMPPwocky 8y agowait, so you can either have one "owner" and transfer ownership between domains (via move) or have shared, but immutable, ownership? Hm. Who let the Rust folks in?
- pmontra 7y agoLanguages cross pollinate. Eventually every language going through the message passing route will reimplement the Erlang VM and OTP...
- jashmatthews 8y agoYeah, I’d much prefer a traditional sub interpreter or isolate design with shared nothing than the current „raise an exception if shared non frozen objects are touched“. It’s much easier to map existing multi process code onto shared nothing sub interpreters.
- Animats 8y agoMove is hard without ownership. Rust can do moves because it knows that there's nothing else pointing to the thing being moved. Python doesn't know that.
- Animats 8y agoNow that's an interesting approach. I proposed something similar for Python 9 years ago.[1] Guido didn't like it. Objects would be either thread-local, shared and locked, or immutable. Thread-local objects must be totally inaccessible from other threads, and not leakable across thread boundaries, for memory safety. (Python has "thread local" objects now, but it's just naming, and not airtight against leaks. You can assign a thread-local object to a global variable.) Shared and locked objects lock when you enter, unlock when you leave. Objects are thread-local by default, so single-thread programs work as before. Minimize shared and locked, while using thread-local or immutable objects as much as possible. Locking is needed only for shared and locked objects. This is almost conventional wisdom today, but 9 years ago, it was too radical. Retrofitting concurrency is never pretty. But we have to. Individual CPUs are about the same speed per thread that they were a decade ago. [1] http://animats.com/papers/languages/pythonconcurrency.html http://animats.com/papers/languages/pythonconcurrency.html