TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Proposal of a new concurrency model for Ruby 3 [pdf]

188 点作者 tenderlove超过 8 年前

16 条评论

pmontra超过 8 年前
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:<p>* Guild has at least one thread (and a thread has at least one fiber)<p>* Threads in different guilds can run in parallel<p>* Threads in a same guild can not run in parallel because of GVL (or GGL: Giant Guild Lock)<p>A guild can&#x27;t access the objects of other guilds.<p>About channels:<p>* We have Guild::Channel to communicate each other<p>* 2 communication methods<p>1. Copy<p>2. Transfer membership or Move in short<p>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.<p>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 <a href="https:&#x2F;&#x2F;ruby-doc.org&#x2F;core-2.3.1&#x2F;Object.html#method-i-freeze" rel="nofollow">https:&#x2F;&#x2F;ruby-doc.org&#x2F;core-2.3.1&#x2F;Object.html#method-i-freeze</a><p>They already did some encouraging benchmarks.
评论 #12453325 未加载
评论 #12454758 未加载
评论 #12452187 未加载
评论 #12451498 未加载
_ko1超过 8 年前
Could you link to <a href="http:&#x2F;&#x2F;www.atdot.net&#x2F;~ko1&#x2F;activities&#x2F;2016_rubykaigi.pdf" rel="nofollow">http:&#x2F;&#x2F;www.atdot.net&#x2F;~ko1&#x2F;activities&#x2F;2016_rubykaigi.pdf</a> ? current one is on temporary file space (will be removed soon).
评论 #12450918 未加载
kent1超过 8 年前
I worked on a similar proposal during my PhD thesis. It is formalized for a Java-like language and implemented in the Jikes RVM. We also carried a proof of isolation using Coq.<p><a href="https:&#x2F;&#x2F;tel.archives-ouvertes.fr&#x2F;tel-00933072" rel="nofollow">https:&#x2F;&#x2F;tel.archives-ouvertes.fr&#x2F;tel-00933072</a>
评论 #12455056 未加载
jph超过 8 年前
The key points IMHO:<p>1. This Ruby 3 proposal says that Ruby 2 compatibility is mission critical, therefore this proposal rejects concurrency solutions from other languages (e.g. Erlang) and concepts (e.g. functions) and data structures (e.g. immutable collections).<p>2 Instead the proposal is to create a fast copy-on-write with rules to &quot;deep freeze&quot; some kinds of objects and primitives into an immutable sharable state.
评论 #12453859 未加载
readittwice超过 8 年前
Hmm, I am wondering how moving ownership would work in a GC&#x27;ed system. You could have arbitrarily many references to the moved object (or subobjects). The slides say that an exception is thrown if an object of a different guild is accessed, but doesn&#x27;t that mean that Ruby needs to check the guild at every object access?<p>Transfering ownership would probably also mean that Ruby not only needs to move one object but probably all subobjects recursively as well. I assume here that &quot;moving&quot; just means updating the guild field for each object.<p>Is this really feasible or wouldn&#x27;t just copying the object be faster... I don&#x27;t know of any system with gc that uses moving to transfer mutable objects between threads. Do such systems exist? Are there better ways of implementing this?
评论 #12451132 未加载
评论 #12452544 未加载
评论 #12453241 未加载
transfire超过 8 年前
Hope thy improve the syntax, it looks horrid -- code in strings and all.
评论 #12457789 未加载
masterleep超过 8 年前
How would you use this to parallelize Rails requests? I guess you would need a pool of guilds, each with its own set of controllers, etc.<p>Since the requests would not be in the &quot;main&quot; guild, it might be painful to call into gems.
评论 #12450767 未加载
ivoras超过 8 年前
Ok, &quot;guilds&quot;? Is the principle behind this so much different than everything done before that it requires repurposing a completely new word?<p>On par with That&#x27;s &quot;crates&quot;. Gives the impression some people just want to be remembered as inventing names.
评论 #12455851 未加载
DougBarth超过 8 年前
If I&#x27;m reading this proposal correctly, locks will still be needed within multithreaded guilds to guard mutations against complex object graphs.<p>Here&#x27;s my reasoning. Since the GVL is insufficient to guard against data races on Ruby 2, under the guild system, locks would be needed to guard against concurrency issues if multiple threads are present.<p>It would seem like the intention would be to replace usages of Thread with Guild to avoid the concurrency issues inherent with threaded code. Will there be API support to create a Guild that only allows a single thread?
评论 #12456064 未加载
评论 #12453850 未加载
DanWaterworth超过 8 年前
This is interesting. It doesn&#x27;t mention GC, but since frozen objects can be shared between guilds, I assume the GC remains global. Perhaps this will trigger interest in immutable datastructures in ruby.
评论 #12453372 未加载
zeckalpha超过 8 年前
How does this compare to the ongoing efforts to remove the GIL in Python? It looks like the Ruby GVL would stay, but be scoped to a Guild, rather than a Process?
评论 #12451436 未加载
评论 #12451178 未加载
评论 #12450760 未加载
评论 #12450748 未加载
sciurus超过 8 年前
This reminds me in some ways of Eric Snow&#x27;s (rejected, afaik) proposal to extend &quot;subinterpreters&quot; to allow parallelism in Python.<p><a href="https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;650489&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lwn.net&#x2F;Articles&#x2F;650489&#x2F;</a>
jellymann超过 8 年前
The PDF appears to have been removed. I&#x27;m getting a &quot;Not Found&quot; page.
gamesbrainiac超过 8 年前
Any idea where the video of the talk is?
评论 #12451783 未加载
评论 #12451784 未加载
claudiug超过 8 年前
do we have any date from this new way of doing concurrency in ruby?
评论 #12451522 未加载
porges超过 8 年前
I{HEART}COM